參考Demo:https://github.com/nicklockwood/iCarousel
作者是英國 Charcoal Design 公司的創(chuàng)始人,這是一款可以在 iOS 上實現(xiàn)旋轉木馬視圖切換效果的第三方控件, 并提供多種切換效果。
1.iCarousel支持以下內(nèi)置顯示類型:
iCarouselTypeLinear
iCarouselTypeRotary
iCarouselTypeInvertedRotary
iCarouselTypeCylinder
iCarouselTypeInvertedCylinder
iCarouselTypeWheel
iCarouselTypeInvertedWheel
iCarouselTypeCoverFlow
iCarouselTypeCoverflow2
iCarouselTypeTimeMachine
iCarouselTypeInvertedTimeMachine
自定義類型:iCarouselTypeCustom
2.使用方法:
將view的類設為iCarousel,使用iCarousel的協(xié)議,然后設置delegate和dataSource。
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel,設置顯示在iCarousel上的元素的個數(shù);
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view;設置在iCarousel上顯示的內(nèi)容
- (void)carouselDidEndScrollingAnimation:(iCarousel *),可以獲得icarousel上停止滑動時當前的元素,因為iCarousel有一個屬性是currentItemIndex;
- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value,可以設置iCarousel的一些屬性,比如說可以設置可滑動顯示的內(nèi)容可以循環(huán)顯示,還可以設置每個元素的高度,每次顯示多少個元素等等。
3.參考資料:如何輕松實現(xiàn)iOS9多任務管理器效果(iCarousel高級教程) - CocoaChina_讓移動開發(fā)更簡單