Documentation
Supported OS & SDK Versions
支持的OS & SDK版本
Supported build target - iOS 5.1 / Mac OS 10.7 (Xcode4.3.3, Apple LLVM compiler 3.1)
支持的编译目标-iOS 5.1 / Mac OS 10.7 (Xcode 4.3.3, Apple LLVM compiler3.1)
Earliest supported deployment target - iOS 4.3 / Mac OS10.7
最早支持的开发目标-iOS 4.3 / Mac OS 10.7
Earliest compatible deployment target - iOS 3.2 / Mac OS10.6
最早兼容的开发目标-iOS 3.2 / Mac OS10.6
NOTE: 'Supported' means that the library has been testedwith this version. 'Compatible' means that the library should work on this OSversion (i.e. it doesn't rely on any unavailable SDK features) but is no longerbeing tested for compatibility and may require tweaking or bug fixes to runcorrectly.
注意:“支持”的意思是这个版本的库已经被测试过了。“可兼容”的意思是在这个版本上这个库是可以工作的(它并不依赖于任何不可获得的sdk特性)但是已经不再对兼容性做测试,并且可能需要稍作改动或bug修复来正确运行。
ARC Compatibility
arc兼容性
As of version 1.6.1, iCarousel automatically works withboth ARC and non-ARC projects through conditional compilation. There is no needto exclude iCarousel files from the ARC validation process, or to convertiCarousel using the ARC conversion tool.
作为1.6.1版本,iCarousel通过条件性编译,可以自动工作在arc和非arc的工程中。没有必要从arc确认程序中排除iCarousel文件,或者去使用arc转换工具去转换iCarousel。
Thread Safety
线程安全
iCarousel is derived from UIView and - as with all UIKitcomponents - it should only be accessed from the main thread. You may wish touse threads for loading or updating carousel contents or items, but alwaysensure that once your content has loaded, you switch back to the main threadbefore updating the carousel.
iCarousel源于UIView,并且-和所有UIKit组建一样-它只能从主线程中获取。你可能希望使用线程来下载或更新carousel内容或条目,但是总是确保一旦你的内容已经被加载了,在更新carousel之前你需要切换回主线程。
Installation
安装
To use the iCarousel class in an app, just drag theiCarousel class files (demo files and assets are not needed) into your projectand add the QuartzCore framework.
在app中使用iCarousel类,只需要将iCarousel类文件(示例文件和“资产”不需要)拖拽到你的工程中,并且添加QuartzCore framework。
Chameleon Support
变色龙支持
iCarousel is now compatible with the Chameleon iOS-to-Macconversion library (https://github.com/BigZaphod/Chameleon). To use iCarouselwith Chameleon, addUSING_CHAMELEONto your project's preprocessor macros.Check out theChameleon Demoexample project for how to port your iOS iCarousel app to Mac OS usingChameleon - the example demonstrates how to run the No Nib iPhone example onMac OS using Chameleon. Note that tap-to-center doesn't currently work, andscrolling must be done using a two-fingered scroll gesture, not click-and-drag(both of these are due to features/limitations of the ChameleonUIGestureRecognizer implementation).
iCarousel现在与变色龙iOS-to-Mac转换库兼容(https://github.com/BigZaphod/Chameleon)。在使用带有变色龙的iCarousel时,在你工程的预处理程序宏定义中添加USING_CHAMELEON 。如何使用变色龙把你的iOS iCarousel app整体搬移到Mac OS请查看Chameleon示例工程。注意,tap-to-center目前是不工作的,并且,滚动必须使用2个手指滚动手势才能完成,而不是点击和拖动(这些都是由于Chameleon手势识别器的实现上的特点/限制)。
Carousel Types
Carousel类型
iCarousel supportsthe following built-in display types:
Carousel支持以下内置的展示样式:
iCarouselTypeLinear
线性的
iCarouselTypeRotary
可旋转的
iCarouselTypeInvertedRotary
反向旋转式
iCarouselTypeCylinder
圆柱式
iCarouselTypeInvertedCylinder
反向圆柱式
iCarouselTypeWheel
车轮式
iCarouselTypeInvertedWheel
反向车轮式
iCarouselTypeCoverFlow
封面流
iCarouselTypeCoverflow2
封面流样式2
iCarouselTypeTimeMachine
时光机
iCarouselTypeInvertedTimeMachine
反向时光机
You can alsoimplement your own bespoke carousel styles usingiCarouselTypeCustomand thecarousel:itemTransformForOffset:baseTransform:delegate method.
你也可以使用iCarouselTypeCustom和carousel:itemTransformForOffset:baseTransform:代理方法来实现自己的定制carousel样式
NOTE: Thedifference betweeniCarouselTypeCoverFlowandiCarouselTypeCoverFlow2types is quite subtle, however the logic foriCarouselTypeCoverFlow2is substantially more complex. If you flick the carousel they arebasically identical, but if you drag the carousel slowly with your finger thedifference should be apparent.iCarouselTypeCoverFlow2is designed to simulate the standard Apple CoverFlow effect as closely aspossible and may change subtly in future in the interests of that goal.
注意:iCarouselTypeCoverFlow和iCarouselTypeCoverFlow2样式的不同之处很细微,然而,iCarouselTypeCoverFlow2的逻辑相当复杂。如果你轻弹carousel,他们基本上是一样的,但是如果你使用手指慢慢拖动carousel,不同点就会明显。iCarouselTypeCoverFlow2是为了模拟尽可能接近标准的苹果封面流效果而设计的,并且可能在未来会为了这个目标而巧妙地变化。
Properties
属性
The iCarousel hasthe following properties (note: for Mac OS, substitute NSView for UIView whenusing properties):
iCarousel有以下属性(注意:对于Mac OS,当使用属性时用NSView替换UIView)
@property(nonatomic,weak)IBOutletid dataSource;
An object thatsupports the iCarouselDataSource protocol and can provide views to populate thecarousel.
一个支持iCarouselDataSource协议且能提供视图来填充carousel的对象。
@property(nonatomic,weak)IBOutletiddelegate;
An object thatsupports the iCarouselDelegate protocol and can respond to carousel events andlayout requests.
一个支持iCarouselDelegate协议且可以响应iCarousel事件和布局请求的对象。
@property(nonatomic,assign)iCarouselType type;
Used to switch thecarousel display type (see above for details).
用来变换carousel展示样式(细节见上文)
@property(nonatomic,assign)CGFloatperspective;
Used to tweak theperspective foreshortening effect for the various 3D carousel views. Should bea negative value, less than 0 and greater than -0.01. Values outside of thisrange will yield very strange results. The default is -1/500, or -0.005;
用来稍稍调整在多种3dcarousel视图中视觉按照透视法缩短效果的,它应该是一个负数,小于0且大于-0.01,这个范围之外的值将会产生非常奇怪的结果。默认值是-1/500, or -0.005。
@property(nonatomic,assign)CGSizecontentOffset;
This property isused to adjust the offset of the carousel item views relative to the center ofthe carousel. It defaults to CGSizeZero, meaning that the carousel items arecentered. Changing this value moves the carousel itemswithoutchanging theirperspective, i.e. the vanishing point moves with the carousel items, so if youmove the carousel items down, itdoes notappear as if you are looking down on the carousel.
这个属性用来调整carousel item views相对于carousel中心的边距。它的默认值是CGSizeZero,意思是carousel items是居中的。改变这个属性的值来移动carousel items而不必改变他们的视觉。消失点随着carousel items移动,所以,如果你把carousel items移动到下边,如果你在carousel上向下看时他就不会出现。
@property(nonatomic,assign)CGSizeviewpointOffset;
This property isused to adjust the user viewpoint relative to the carousel items. It has theopposite effect to adjusting the contentOffset, i.e. if you move the viewpointup then the carousel appears to move down. Unlike the contentOffset, moving theviewpoint also changes the perspective vanishing point relative to the carouselitems, so if you move the viewpoint up, it will appear as if you are lookingdown on the carousel.
这个属性用来调整相对于carousel items的用户视点,它有一个副作用就是调整contentOffset。如果你向上移动视点,然后carousel显示是向下移动。与contentOffset不同,移动视点也会改变和carousel items有关的视角消失点,所以如果你向上移动视点,他就会像你在carousel上向下看一样出现。
@property(nonatomic,assign)CGFloatdecelerationRate;
The rate at whichthe carousel decelerates when flicked. Higher values mean slower deceleration.The default value is 0.95. Values should be in the range 0.0 (carousel stopsimmediately when released) to 1.0 (carousel continues indefinitely withoutslowing down, unless it reaches the end).
这个率用于carousel被快速轻击时carousel减速率。值越大表示减速越慢。默认值是0.95.值应该在0.0(设置为这个值时,carousel被释放时立即停止滚动)和1.0(设置为这个值时,carousel继续无限滚动而不减速,直到它到达底部)之间。
@property(nonatomic,assign)BOOL bounces;
Sets whether thecarousel should bounce past the end and return, or stop dead. Note that thishas no effect on carousel types that are designed to wrap, or where thecarouselShouldWrap delegate method returns YES.
设置carousel在超出底部和返回时是否应该弹跳,或者是停止并挂掉。注意,在carousel样式设置为缠绕样式时或者carouselShouldWrap代理方法返回为yes时,这个属性不起作用。
@property(nonatomic,assign)CGFloatbounceDistance;
The maximumdistance that a non-wrapped carousel will bounce when it overshoots the end.This is measured in multiples of the itemWidth, so a value of 1.0 would meansthe carousel will bounce by one whole item width, a value of 0.5 would be halfan item's width, and so on. The default value is 1.0;
一个非包裹样式的carousel在超过底部时将弹跳的最大距离。这个用itemWidth的倍数来衡量的,所以1.0这个值意味着弹跳一整个item的宽度,0.5这个值是一个item宽度的一半,以此类推。默认值是1.0.
@property(nonatomic,assign,getter=isScrollEnabled)BOOL scrollEnabled;
Enables anddisables user scrolling of the carousel. The carousel can still be scrolledprogrammatically if this property is set to NO.
使能或者禁止用户滚动carousel。如果这个值被设为no,carousel仍然可以以编程方式被滚动。
@property(nonatomic,readonly,getter=isWrapEnabled)BOOL wrapEnabled;
Returns YES ifwrapping is enabled and NO if it isn't. This property is read only. If you wishto override the default value, implement thecarousel:valueForOption:withDefault:delegate method and return a value foriCarouselOptionWrap.
如果打包被使能的话,返回yes,如果不是返回no。这个属性是只读的。如果你想重写这个默认值,实现carousel:valueForOption:withDefault:方法且给iCarouselOptionWrap返回一个值。
@property(nonatomic,readonly)NSIntegernumberOfItems;
The number of itemsin the carousel (read only). To set this, implement thenumberOfItemsInCarousel:dataSource method. Note that not all of these item views will be loaded orvisible at a given point in time - the carousel loads item views on demand asit scrolls.
carousel中items的数量(只读),要设置他的话,实现numberOfItemsInCarousel:这个数据源方法。注意,所有这些item views在一个给定的时间点将会被加载或者可见-carousel当它滚动的时候经要求加载item views。
@property(nonatomic,readonly)NSIntegernumberOfPlaceholders;
The number ofplaceholder views to display in the carousel (read only). To set this,implement thenumberOfPlaceholdersInCarousel:dataSource method.
在carousel中展示的占位视图的数量(只读)。要设置他,实现一下numberOfPlaceholdersInCarousel:这个数据源方法。
@property(nonatomic,readonly)NSIntegernumberOfVisibleItems;
The maximum numberof carousel item views to be displayed concurrently on screen (read only). Thisproperty is important for performance optimisation, and is calculatedautomatically based on the carousel type and view frame. If you wish tooverride the default value, implement thecarousel:valueForOption:withDefault:delegate method and return a value for iCarouselOptionVisibleItems.
同时显示在屏幕上的carousel itemviews的最大数量(只读)。这个属性对执行最优化很重要,且是基于carousel的样式和视图的frame被自动计算的。如果你想重写这个默认值,实现一下carousel:valueForOption:withDefault:(原文件中没有找到这个方法????工程中使用的是- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel数据源方法)这个代理方法且给iCarouselOptionVisibleItems返回一个值。
@property(nonatomic,strong,readonly)NSArray*indexesForVisibleItems;
An array containingthe indexes of all item views currently loaded and visible in the carousel,including placeholder views. The array contains NSNumber objects whose integervalues match the indexes of the views. The indexes for item views start at zeroand match the indexes passed to the dataSource to load the view, however theindexes for any visible placeholder views will either be negative (less thanzero) or greater than or equal tonumberOfItems. Indexes forplaceholder views in this arraydo notequate to the placeholder view index used with the dataSource.
一个包含了所有当前加载的和在carousel中可见的item views的索引,包括占位视图的数组,这个数组包含NSNumber的对象,他们的整数值与视图的索引匹配。这些item views的索引从0开始且与加载视图时数据源传递的索引匹配,然而,任何占位视图的索引将是负数或者大于等于numberOfItems。数组中的placeholder views的索引并不等于数据源中使用的占位视图的索引。
@property(nonatomic,strong,readonly)NSArray*visibleItemViews;
An array of all theitem views currently displayed in the carousel (read only). This includes anyvisible placeholder views. The indexes of views in this array do not match theitem indexes, however the order of these views matches the order of thevisibleItemIndexes array property, i.e. you can get the item index of a givenview in this array by retrieving the equivalent object from thevisibleItemIndexes array (or, you can just use theindexOfItemView:method, which ismuch easier).
一个存放当前carousel中展示的所有item views的数组(只读),它包括任何可见的占位视图。这个数组中视图的索引并不与item的索引匹配,然而,这些视图的顺序与visibleItemIndexes数组属性中的顺序匹配,你可以通过从visibleItemIndexes数组中去掉??对应的对象来在这个数组中获取一个指定视图的索引(或者,你可以仅仅用indexOfItemView:方法,这个会更简单)
@property(nonatomic,strong,readonly)UIView*contentView;
The view containingthe carousel item views. You can add subviews to this view if you want tointersperse them with the carousel items. If you want a view to appear in frontor behind all of the carousel items, you should add it directly to theiCarousel view itself instead. Note that the order of views inside the contentViewis subject to frequent and undocumented change whilst the app is running. Anyviews added to the contentView should have their userInteractionEnabledproperty set to NO to prevent conflicts with iCarousel's touch event handling.
包含carouselitem views的视图。你可以增加子视图如果你想用这些carousel items散置这些视图。如果你想让一个视图出现在所有carouselitems的前边或者后边,你应该直接添加它到iCarousel view本身来替代。注意,在contentView中视图的顺序是受当app执行时的频率和未标注的变化决定的。任何添加到contentView中的视图应该将他们的userInteractionEnabled属性设置为no来防止和iCarousel的触摸时间处理放生冲突。
@property(nonatomic,assign)CGFloatscrollOffset;
This is the currentscroll offset of the carousel in multiples of the itemWidth. This value,rounded to the nearest integer, is the currentItemIndex value. You can use thisvalue to position other screen elements while the carousel is in motion. Thevalue can also be set if you wish to scroll the carousel to a particular offsetprogrammatically. This may be useful if you wish to disable the built-ingesture handling and provide your own implementation.
这是以itemWidth的整数倍来计算的carousel当前的滚动偏移量,这个值,被截取为最接近的整数,是currentItemIndex值。当carousel运动中,你可以使用这个值定位其他屏幕的元素。这个值也可以被编程方式设置如果你想滚动carousel到一个特定的偏移。如果你想禁用内置手势处理并提供自己的实现时,这个可能有用。
@property(nonatomic,readonly)CGFloatoffsetMultiplier;
This is the offsetmultiplier used when the user drags the carousel with their finger. It does notaffect programmatic scrolling or deceleration speed. This defaults to 1.0 formost carousel types, but defaults to 2.0 for the CoverFlow-style carousels to compensatefor the fact that their items are more closely spaced and so must be draggedfurther to move the same distance. You cannot set this property directly, butyou can override the default value by implementing thecarouselOffsetMultiplier:delegate method.
这是当用户用手指拖动carousel时偏移量的乘数。它并不影响编程的滚动和减速的速度。对大多数carousel样式这个默认值是1.0,但是对CoverFlow-style样式的carousels默认值是2.0,来弥补他们的items在空间上更紧凑,所以必须拖拽更远来移动相同的距离的事实。你不能直接设置这个值,但是可以通过实现carouselOffsetMultiplier:代理方法来重写默认值。
这个应该是滑动一下移动的距离。
@property(nonatomic,assign)NSIntegercurrentItemIndex;
The index of thecurrently centered item in the carousel. Setting this property is equivalent tocallingscrollToItemAtIndex:animated:with the animated argument set to NO.
当前carousel中居中的item的索引,设置这个属性相当于调用scrollToItemAtIndex:animated:方法时将animated参数设置为no。
@property(nonatomic,strong,readonly)UIView*currentItemView;
The currently centered item view in the carousel. Theindex of this view matchescurrentItemIndex.
当前carousel中居中的item view。这个视图的索引与currentItemIndex匹配。
@property(nonatomic,readonly)CGFloatitemWidth;
The display widthof items in the carousel (read only). This is derived automatically from thefirst view passed in to the carousel using thecarousel:viewForItemAtIndex:reusingView:dataSource method.You can also override this value using thecarouselItemWidth:delegate method, which will alter the space allocated for carousel items(but won't resize or scale the item views).
carousel中展示的items的宽度(只读)。这是自动从使用carousel:viewForItemAtIndex:reusingView:数据源方法第一个传到carousel中的视图中继承来的。你也可以使用carouselItemWidth:代理方法重写这个值,这个方法会改变分配给carousel items的空间(但是不会对这些item views重写设置大小或规模)。
@property(nonatomic,assign)BOOL centerItemWhenSelected;
When set to YES,tapping any item in the carousel other than the one matching thecurrentItemIndex will cause it to smoothly animate to the center. Tapping thecurrently selected item will have no effect. Defaults to YES.
当设置为yes时,点击任何在carousel中的item而不是那个匹配currentItemIndex的视图,将会使平滑动画移动到居中位置。点击当前被选中的item将没有效果。默认值是yes。
@property(nonatomic,assign)CGFloatscrollSpeed;
This is the scrollspeed multiplier when the user flicks the carousel with their finger. Defaultsto 1.0.
这是当用户用手指轻击carousel时滚动速度乘数。默认值是1.0.
@property(nonatomic,readonly)CGFloattoggle(切换键);
This property isused for theiCarouselTypeCoverFlow2carousel transform. It is exposed so that you can implement your ownvariants of the CoverFlow2 style using thecarousel:itemTransformForOffset:baseTransform:delegate method.
这个属性用于iCarouselTypeCoverFlow2的carousel变换。它是被暴露的以便于你可以使用carousel:itemTransformForOffset:baseTransform:代理方法实现自己的CoverFlow2样式变量。
@property(nonatomic,assign)BOOL stopAtItemBoundary;
By default, thecarousel will come to rest at an exact item boundary when it is flicked. If youset this property to NO, it will stop naturally and then - ifscrollToItemBoundary is set to YES - scroll back or forwards to the nearestboundary.
默认情况下,carousel被轻击时会停在一个准确的item边界。如果你设置这个值为no,他会自然停止然后-如果scrollToItemBoundary被设置为yes-滚回或者向前滚动到最接近的边界
@property(nonatomic,assign)BOOL scrollToItemBoundary;
By default wheneverthe carousel stops moving it will automatically scroll to the nearest itemboundary. If you set this property to NO, the carousel will not scroll afterstopping and will stay wherever it is, even if it's not perfectly aligned onthe current index. The exception to this is that if wrapping is disabled andbouncesis set to YES thenregardless of this setting, the carousel will automatically scroll back to thefirst or last item index if it comes to rest beyond the end of the carousel.
默认情况下,不管carousel何时停止移动,他会自动滚动到最近的item边界。如果你设置这个属性为no,carousel停止后将不会滚动且不管在哪儿他都会停下来,即使他不是正好对准当前的索引。有一个特例,如果打包效果被禁止且bounces呗设置为yes,然后,不管这个设置是什么,carousel会自动滚回第一个或者最后一个索引,如果它停下来时超出了carousel的底部。
@property(nonatomic,assign)BOOL useDisplayLink;
By default on iOSiCarousel will use CADisplayLink instead of NSTimer for animations. On Mac OS,the CVDisplayLink API is used instead. This provides better synchronisationwith the screen refresh, but can occasionally prevents the animation workingproperly when the carousel is combined with other views or animations. If youfind that the carousel is not continuing to move after being dragged, trysetting this property to NO.
在默认情况下,在iOS中iCarousel会使用CADisplayLink而不是NSTimer来进行动画。在Mac OS上,使用的却是CVDisplayLinkAPI。这个在屏幕刷新时提供了更好的同步效果,但是当carousel与其他视图或动画结合,有时会妨碍动画正常运行。如果你发现carousel被拖动后没有持续移动,试一下把这个属性置为no。
@property(nonatomic,assign,getter=isVertical)BOOL vertical;
This propertytoggles whether the carousel is displayed horizontally or vertically on screen.All the built-in carousel types work in both orientations. Switching tovertical changes both the layout of the carousel and also the direction ofswipe detection on screen. Note that custom carousel transforms are notaffected by this property, however the swipe gesture direction will still beaffected.
这个属性切换,不管carousel是水平展示还是垂直展示的。所有内嵌的carousel样式在这两个方向上都可以运行。切换到垂直将会改变carousel的布局和屏幕上的切换方向。注意,自定义的carousel变换不受这个属性影响,但是,切换手势的方向还是会受影响。
@property(nonatomic,assign)BOOL ignorePerpendicularSwipes;
If YES, thecarousel will ignore swipe gestures that are perpendicular to the orientationof the carousel. So for a horizontal carousel, vertical swipes will not beintercepted. This means that you can have a vertically scrolling scrollViewinside a carousel item view and it will still function correctly. Defaults toYES.
如果为yes,carousel将会忽略垂直于carousel方向的切换手势。目前,一个水平的carousel,垂直切换将不会被拦截。这就意味着你可以获得一个在carouselitem view里的垂直滚动的scrollView切它依然会正确工作。默认值为yes。
@property(nonatomic,assign)BOOL clipsToBounds;
This is actuallynot a property of iCarousel but is inherited from UIView. It's included herebecause it's a frequently missed feature. Set this to YES to prevent thecarousel item views overflowing their bounds. You can set this property inInterface Builder by ticking the 'Clip Subviews' option. Defaults to NO.
这个实际上不是iCarousel的属性,但是是从UIView继承来的。它被包含在这里是因为他是一个经常被漏掉的特性。设置为yes来防止carousel item views超出他们的界限。你可以在InterfaceBuilder里通过点击'Clip Subviews'选项来设置这个属性。默认值是no。
Methods
方法
The iCarousel classhas the following methods (note: for Mac OS, substitute NSView for UIView inmethod arguments):
iCarousel类有以下方法(注意:对于Mac OS,在方法的参数中用NSView来代替UIView)
-(void)scrollToItemAtIndex:(NSInteger)indexanimated:(BOOL)animated;
This will centerthe carousel on the specified item, either immediately or with a smoothanimation. For wrapped carousels, the carousel will automatically determine theshortest (direct or wraparound) distance to scroll. If you need to control thescroll direction, or want to scroll by more than one revolution, use thescrollByNumberOfItems method instead.
这个方法会使carousel居中在一个特定的item,立即或者使用一个平滑的动画。对于打包的carousels,carousel将会自动决定滚动的最短(直线会或者包着的)距离。如果你需要控制这个滚动的方向,或者想滚动多于一个分辨率,使用scrollByNumberOfItems这个方法。
-(void)scrollToItemAtIndex:(NSInteger)indexduration:(NSTimeInterval)scrollDuration;
This method allowsyou to control how long the carousel takes to scroll to the specified index.
这个方法允许你来控制carousel使用多长时间来滚动到特定的索引。
-(void)scrollByNumberOfItems:(NSInteger)itemCountduration:(NSTimeInterval)duration;
This method allowsyou to scroll the carousel by a fixed distance, measured in carousel itemwidths. Positive or negative values may be specified for itemCount, dependingon the direction you wish to scroll. iCarousel gracefully handles boundsissues, so if you specify a distance greater than the number of items in thecarousel, scrolling will either be clamped when it reaches the end of thecarousel (if wrapping is disabled) or wrap around seamlessly.
这个方法允许你使用一个固定的距离滚动carousel,以carousel的item宽度来衡量。整数或负数可能由itemCount来具体确定,取决于你希望滚动的方向。iCarousel很好的处理了边界问题,所以如果你指定了一个大于carousel中items数量的值,滚动或者在到达carousel底部时被夹紧(如果打包被禁止),或者无停顿地包裹。
-(void)scrollToOffset:(CGFloat)offsetduration:(NSTimeInterval)duration;
This works the same way asscrollToItemAtIndex:, but allows you toscroll to a fractional offset. This may be useful if you wish to achieve a veryprecise animation effect. Note that if thescrollToItemBoundaryproperty is set to YES, the carousel will automatically scroll to thenearest item index after you call this method. anyway.
这个方法工作起来和scrollToItemAtIndex:方法一样,但是允许你移动到一个微小的偏移。如果你想达到一个非常准确的动画效果时这个可能有用。注意,如果scrollToItemBoundary属性被设置为yes,当你调用这个方法之后carousel会自动滚动到最近的item索引。
-(void)scrollByOffset:(CGFloat)offsetduration:(NSTimeInterval)duration;
This works the sameway asscrollByNumberOfItems:, but allows you toscroll by a fractional number of items. This may be useful if you wish toachieve a very precise animation effect. Note that if thescrollToItemBoundaryproperty is set to YES, the carousel will automatically scroll to thenearest item index after you call this method anyway.
这个方法作用与scrollByNumberOfItems:方法一样,但是允许你滚动到一个微小数量的items。如果你想达到一个非常准确的动画效果时可能有用。注意,如果scrollToItemBoundary属性被设置为yes,在你调用这个方法后carousel无论如何会自动滚动到最近一个item索引。
(这个应该是滚动几个items)
-(void)reloadData;
This reloads allcarousel views from the dataSource and refreshes the carousel display.
这个方法重新从数据源加载carousel视图并刷新carousel的显示。
-(UIView*)itemViewAtIndex:(NSInteger)index;
Returns the visibleitem view with the specified index. Note that the index relates to the positionin the carousel, and not the position in thevisibleItemViewsarray, which may bedifferent. Pass a negative index or one greater than or equal tonumberOfItemsto retrieveplaceholder views. The method only works for visible item views and will returnnil if the view at the specified index has not been loaded, or if the index isout of bounds.
返回带有指定索引的可见的item视图。注意,这个索引和carousel的位置有关,且不是在visibleItemViews数组中的位置,这可能是不一样的。传递一个赋值或者一个大于等于numberOfItems的整数来取回占位视图。这个方法只有在是可见视图且情况下才工作,且如果这个在指定索引处的视图还没被加载时,或者这个索引超出范围时,将返回空。
-(NSInteger)indexOfItemView:(UIView*)view;
The index for agiven item view in the carousel. Works for item views and placeholder views,however placeholder view indexes do not match the ones used by the dataSourceand may be negative (seeindexesForVisibleItemsproperty above for more details). This method only works for visible itemviews and will return NSNotFound for views that are not currently loaded. For alist of all currently loaded views, use thevisibleItemViewsproperty.
这个是carousel中指定item view的索引。对item views和placeholder views起作用,但是,placeholder view索引并不和数据源中的索引匹配,且有可能是负值。(查看上面indexesForVisibleItems属性介绍的细节)。这个方法只对可见的item views起作用且对目前没有加载的视图会返回NSNotFound。对于一列所有加载的视图,使用visibleItemViews属性。
-(NSInteger)indexOfItemViewOrSubview:(UIView*)view
This method givesyou the item index of either the view passed or the view containing the viewpassed as a parameter. It works by walking up the view hierarchy starting withthe view passed until it finds an item view and returns its index within thecarousel. If no currently-loaded item view is found, it returns NSNotFound.This method is extremely useful for handling events on controls embedded withinan item view. This allows you to bind all your item controls to a single actionmethod on your view controller, and then work out which item the control thattriggered the action was related to. You can see an example of this techniquein theControls Demoexample project.
这个方法给你或者是传递的视图或者是包含有作为参数的视图的视图的item索引。它通过以传递进来的视图为开始,向上遍历视图层级,直到找到一个itemview并返回他在carousel中的索引。如果没有找到当前加载的item view,它会返回NSNotFound。这个方法对处理一个item view内嵌的事件控制极其有用。它允许你绑定你的在控制器中控制单一行为方法的item,且会找出控制触发相关行为的item。你可以看一下在Controls Demoexample工程中这个技术的例子。
看到这儿了!
-(CGFloat)offsetForItemAtIndex:(NSInteger)index;
Returns the offsetfor the specified item index in multiples ofitemWidthfrom the centerposition. This is the same value used for calculating the view transform andalpha, and can be used to customise item views based on their position in thecarousel. This value can be expected to change for each view whenever thecarouselDidScroll:delegate method is called.
返回以itemWidth整数倍来记的指定的item索引处的偏移量
-(void)removeItemAtIndex:(NSInteger)indexanimated:(BOOL)animated;
This removes anitem from the carousel. The remaining items will slide across to fill the gap.Note that the data source is not automatically updated when this method iscalled, so a subsequent call to reloadData will restore the removed item.
-(void)insertItemAtIndex:(NSInteger)indexanimated:(BOOL)animated;
This inserts anitem into the carousel. The new item will be requested from the dataSource, somake sure that the new item has been added to the data source data beforecalling this method, or you will get duplicate items in the carousel, or otherweirdness.
-(void)reloadItemAtIndex:(NSInteger)indexanimated:(BOOL)animated;
This method willreload the specified item view. The new item will be requested from thedataSource. If the animated argument is YES, it will cross-fade from the old tothe new item view, otherwise it will swap instantly.
Protocols
协议
The iCarouselfollows the Apple convention for data-driven views by providing two protocolinterfaces, iCarouselDataSource and iCarouselDelegate. The iCarouselDataSourceprotocol has the following required methods (note: for Mac OS, substituteNSView for UIView in method arguments):
-(NSUInteger)numberOfItemsInCarousel:(iCarousel*)carousel;
Return the numberof items (views) in the carousel.
返回carousel中界面的数量
-(UIView*)carousel:(iCarousel*)carouselviewForItemAtIndex:(NSUInteger)index reusingView:(UIView*)view;
Return a view to bedisplayed at the specified index in the carousel. ThereusingViewargument works likea UIPickerView, where views that have previously been displayed in the carouselare passed back to the method to be recycled. If this argument is not nil, youcan set its properties and return it instead of creating a new view instance,which will slightly improve performance. Unlike UITableView, there is noreuseIdentifier for distinguishing between different carousel view types, so ifyour carousel contains multiple different view types then you should justignore this parameter and return a new view each time the method is called. Youshould ensure that each time thecarousel:viewForItemAtIndex:reusingView:method is called, it either returns the reusingView or a brand new viewinstance rather than maintaining your own pool of recyclable views, asreturning multiple copies of the same view for different carousel item indexesmay cause display issues with the carousel.
返回一个在carousel中要在指定索引处显示的视图,reusingView参数的作用就像UIPickerView,之前在carousel中展示过的界面被传递到方法中来循环使用。如果这个参数不是空,你可以设置它的属性并返回它而不是创建一个新的视图实例,这样可以稍改善性能。与UITableView不同,这里没有重用id来区分不同的carousel界面类型。
所以如果你的carousel包含多个不同的视图类型,那么每次这个方法被调用的时候,你应该只是忽略这个参数并返回一个新的视图。你应该确认carousel:viewForItemAtIndex:reusingView:方法每次被调用时,它要么返回重用的视图,要么返回一个新的视图实例而不是保留你自己的循环视图池,因为为不同的carousel界面索引返回多个相同视图的复制品可能造成显示问题。
TheiCarouselDataSource protocol has the following optional methods:
-(NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel*)carousel;
Returns the numberof placeholder views to display in the carousel. Placeholder views are intendedto be used when the number of items in the carousel is too few to fill thecarousel width, and you wish to display something in the empty space. They movewith the carousel and behave just like any other carousel item, but they do notcount towards the numberOfItems value, and cannot be set as the currentlyselected item. Placeholders are hidden when wrapping is enabled. Placeholdersappear on either side of the carousel items. For n placeholder views, the firstn/2 items will appear to the left of the item views and the next n/2 willappear to the right. You can have an odd number of placeholders, in which casethe carousel will be asymmetrical.
返回在carousel中展示的占位视图。占位视图用来当carousel中界面太少而不能填满carousel的宽度,并且你希望在空白的地方显示一些东西时使用。它们随着carousel移动并且像其他carousel界面一样运行,但是它们不占numberOfItems数量,且不能被设置为当前选中的界面。当打包属性被使能时占位视图被隐藏。占位视图或者显示在carousel界面的任何一方。对于n个占位视图,前n/2个界面将会出现在界面视图的左边,下一个n/2个界面会出现在右边。你可以有奇数个占位视图,这种情况下carousel会是不对称的。
-(UIView*)carousel:(iCarousel*)carouselplaceholderViewAtIndex:(NSUInteger)index reusingView:(UIView*)view;
Return a view to bedisplayed as the placeholder view. Works the same way ascarousel:viewForItemAtIndex:reusingView:. PlaceholderreusingViews are stored in a separate pool to the reusingViews used for regularcarousel, so it's not a problem if your placeholder views are different to theitem views.
TheiCarouselDelegate protocol has the following optional methods:
-(void)carouselWillBeginScrollingAnimation:(iCarousel*)carousel;
This method iscalled whenever the carousel will begin an animated scroll. This can betriggered programatically or automatically after the user finishes scrollingthe carousel, as the carousel re-aligns itself.
-(void)carouselDidEndScrollingAnimation:(iCarousel*)carousel;
This method iscalled when the carousel ends an animated scroll.
-(void)carouselDidScroll:(iCarousel*)carousel;
This method iscalled whenever the carousel is scrolled. It is called regardless of whetherthe carousel was scrolled programatically or through user interaction.
-(void)carouselCurrentItemIndexDidChange:(iCarousel*)carousel;
This method iscalled whenever the carousel scrolls far enough for the currentItemIndexproperty to change. It is called regardless of whether the item index wasupdated programatically or through user interaction.
-(void)carouselWillBeginDragging:(iCarousel*)carousel;
This method iscalled when the user begins dragging the carousel. It will not fire if the usertaps/clicks the carousel, or if the carousel is scrolled programmatically.
-(void)carouselDidEndDragging:(iCarousel*)carousel willDecelerate:(BOOL)decelerate;
This method iscalled when the user stops dragging the carousel. The willDecelerate parameterindicates whether the carousel is travelling fast enough that it needs todecelerate before it stops (i.e. the current index is not necessarily the oneit will stop at) or if it will stop where it is. Note that even ifwillDecelerate is NO, the carousel will still scroll automatically until italigns exactly on the current index. If you need to know when it has stoppedmoving completely, use the carouselDidEndScrollingAnimation delegate method.
-(void)carouselWillBeginDecelerating:(iCarousel*)carousel;
This method iscalled when the carousel starts decelerating. it will typically be calledimmediately after the carouselDidEndDragging:willDecelerate: method, assumingwillDecelerate was YES.
-(void)carouselDidEndDecelerating:(iCarousel*)carousel;
This method iscalled when the carousel finishes decelerating and you can assume that thecurrentItemIndex at this point is the final stopping value. Unlike previousversions, the carousel will now stop exactly on the final index position inmost cases. The only exception is on non-wrapped carousels with bounce enabled,where, if the final stopping position is beyond the end of the carousel, thecarousel will then scroll automatically until it aligns exactly on the endindex. For backwards compatibility, the carousel will always callscrollToItemAtIndex:animated:after it finishes decelerating. If you need to know for certain when thecarousel has stopped moving completely, use thecarouselDidEndScrollingAnimationdelegate method.
-(CGFloat)carouselItemWidth:(iCarousel*)carousel;
Returns the widthof each item in the carousel - i.e. the spacing for each item view. If themethod is not implemented, this defaults to the width of the first item viewthat is returned by thecarousel:viewForItemAtIndex:reusingView:dataSource method. This method should only be used to crop or pad itemviews if the views returned fromcarousel:viewForItemAtIndex:reusingView:are not correct (e.g. if the views are differing sizes, or include a dropshadow or outer glow in their background image that affects their size) - ifyou just want to space out the views a bit then it's better to use theiCarouselOptionSpacingvalue instead.
-(CATransform3D)carousel:(iCarousel*)carouselitemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform;
This method can beused to provide a custom transform for each carousel view. The offset argumentis the distance of the view from the middle of the carousel. The currentlycentred item view would have an offset of 0.0, the one to the right would havean offset value of 1.0, the one to the left an offset value of -1.0, and so on.To implement the linear carousel style, you would therefore simply multiply theoffset value by the item width and use it as the x value of the transform. Thismethod is only called if the carousel type is iCarouselTypeCustom.
-(CGFloat)carousel:(iCarousel*)carouselvalueForOption:(iCarouselOption)option withDefault:(CGFloat)value;
This method is usedto customise the parameters of the standard carousel types. By implementingthis method, you can tweak options such as the number of items displayed in acircular carousel, or the amount of tilt in a coverflow carousel, as well aswhether the carousel should wrap and if it should fade out at the ends, etc.For any option you are not interested in tweaking, just return the defaultvalue. The meaning of these options is listed below underiCarouselOption values. Check theOptions Demofor an advanced example of using this method.
-(void)carousel:(iCarousel*)carousel didSelectItemAtIndex:(NSInteger)index;
This method willfire if the user taps any carousel item view (not including placeholder views),including the currently selected view. This method will not fire if the usertaps a control within the currently selected view (i.e. any view that is asubclass of UIControl).
-(BOOL)carousel:(iCarousel*)carouselshouldSelectItemAtIndex:(NSInteger)index;
This method willfire if the user taps any carousel item view (not including placeholder views),including the currently selected view. The purpose of a method is to give youthe opportunity to ignore a tap on the carousel. If you return YES from themethod, or don't implement it, the tap will be processed as normal and thecarousel:didSelectItemAtIndex:method will be called. If you return NO, the carousel will ignore the tapand it will continue to propagate up the view hierarchy. This is a good way toprevent the carousel intercepting tap events intended for processing by anotherview.
iCarouselOptionvalues
These are the tweakableoptions for standard carousels. Check theOptions Demofor an example ofthe effect that these parameters have.
iCarouselOptionWrap
A booleanindicating whether the carousel should wrap when it scrolls to the end. ReturnYES if you want the carousel to wrap around when it reaches the end, and NO ifyou want it to stop. Generally, circular carousel types will wrap by defaultand linear ones won't. Don't worry that the return type is a floating pointvalue - any value other than 0.0 will be treated as YES.
iCarouselOptionShowBackfaces
For some carouseltypes, e.g. iCarouselTypeCylinder, the rear side of some views can be seen(iCarouselTypeInvertedCylinder now hides the back faces by default). If youwish to hide the backward-facing views you can return NO for this option. Tooverride the default back-face hiding for the iCarouselTypeInvertedCylinder,you can return YES. This option may also be useful for custom carouseltransforms that cause the back face of views to be displayed.
iCarouselOptionOffsetMultiplier
The offsetmultiplier to use when the user drags the carousel with their finger. It doesnot affect programmatic scrolling or deceleration speed. This defaults to 1.0for most carousel types, but defaults to 2.0 for the CoverFlow-style carouselsto compensate for the fact that their items are more closely spaced and so mustbe dragged further to move the same distance.
iCarouselOptionVisibleItems
This is the maximumnumber of item views (including placeholders) that should be visible in thecarousel at once. Half of this number of views will be displayed to either sideof the currently selected item index. Views beyond that will not be loadeduntil they are scrolled into view. This allows for the carousel to contain avery large number of items without adversely affecting performance. iCarouselchooses a suitable default value based on the carousel type, however you maywish to override that value using this property (e.g. if you have implemented acustom carousel type).
iCarouselOptionCount
The number of itemsto be displayed in the Rotary, Cylinder and Wheel transforms. Normally this iscalculated automatically based on the view size and number of items in thecarousel, but you can override this if you want more precise control of thecarousel appearance. This property is used to calculate the carousel radius, soanother option is to manipulate the radius directly.
iCarouselOptionArc
The arc of theRotary, Cylinder and Wheel transforms (in radians). Normally this defaults to2*M_PI (a complete circle) but you can specify a smaller value, so for examplea value of M_PI will create a half-circle or cylinder. This property is used tocalculate the carousel radius and angle step, so another option is tomanipulate those values directly.
iCarouselOptionRadius
The radius of theRotary, Cylinder and Wheel transforms in pixels/points. This is usuallycalculated so that the number of visible items exactly fits into the specifiedarc. You can manipulate this value to increase or reduce the item spacing (andthe radius of the circle).
iCarouselOptionAngle
The angular stepbetween each item in the Rotary, Cylinder and Wheel transforms (in radians).Manipulating this value without changing the radius will cause a gap at the endof the carousel or cause the items to overlap.
iCarouselOptionTilt
The tilt applied tothe non-centered items in the CoverFlow, CoverFlow2 and TimeMachine carouseltypes. This value should be in the range 0.0 to 1.0.
iCarouselOptionSpacing
The spacing betweenitem views. This value is multiplied by the item width (or height, if thecarousel is vertical) to get the total space between each item, so a value of1.0 (the default) means no space between views (unless the views alreadyinclude padding, as they do in many of the example projects).
iCarouselOptionFadeMin
iCarouselOptionFadeMax
iCarouselOptionFadeRange
These three optionscontrol the fading out of carousel item views based on their offset from thecurrently centered item. FadeMin is the minimum negative offset an item viewcan reach before it begins to fade. FadeMax is the maximum positive offset aview can reach before if begins to fade. FadeRange is the distance the item canmove between the point at which it begins to fade and the point at which itbecomes completely invisible.
Detecting Taps onItem Views
There are two basicapproaches to detecting taps on views in iCarousel on iOS. The first approachis to simply use thecarousel:didSelectItemAtIndex:delegate method, which fires every time an item is tapped. If you are onlyinterested in taps on the currently centered item, you can compare thecurrentItemIndexproperty againstthe index parameter of this method.
Alternatively, ifyou want a little more control you can supply a UIButton or UIControl as theitem view and handle the touch interactions yourself. See theButtons Demoexample project foran example of how this is done (doesn't work on Mac OS; see below).
You can also nestUIControls within your item views and these will receive touches as expected(see theControls Demoexample project for an example).
If you wish todetect other types of interaction such as swipes, double taps or long presses,the simplest way is to attach a UIGestureRecognizer to your item view or itssubviews before passing it to the carousel.
Note that taps andgestures will be ignored on any item view except the currently selected one,unless you set thecenterItemWhenSelectedproperty to NO.
On Mac OS there isno easy way to embed controls within iCarousel item views currently. You cannotjust supply an NSButton as or inside your item view because the transformsapplied to the item views mean that hit detection doesn't work properly. I'minvestigating possible solutions to this (if you know a good way to fix this,please get in touch, or fork the project on github).
Example projects
iCarousel includesa number of example projects to help you get started. Here is a lift and briefdescription for each:
BasiciOSExample
This is a verysimple example for iOS that demonstrates setting up a carousel with theiCarouselCoverflow2 type.
iOSDemo
This is a morecomplex iOS demo app that shows off all the different carousel types andadditional features such as dynamic insertion/deletion of items.
MacDemo
This is a Mac OSport of the iOS Demo example, which replicates all the same functionality.
ButtonsDemo
This example demonstrateshow to use UIButtons as your item views on iOS and correctly handle the events.
ControlsDemo
This exampledemonstrates how to nest controls within your item views on iOS and correctlyhandle the events, as well as how to load complex item views from a nib fileinstead of generating them in code.
MultipleCarousels
This exampledemonstrates how to use multiple carousels within a single view controller.
NoNibDemo
This exampledemonstrates how to set up iCarousel without using a nib file on iOS.
StoryboardDemo
This exampledemonstrates how to set up iCarousel using Storyboards on iOS 5 and above.
OffsetsDemo
This exampledemonstrates how to use thecontentOffsetandviewpointOffsetproperties, and the effect they have.
OptionsDemo
This example demonstrateshow to customise the appearance of each carousel type using the iCarouselOptionAPI.
DynamicViewReflections
This exampledemonstrates how to use the ReflectionView class(https://github.com/nicklockwood/ReflectionView) to dynamically generatereflections for your item views. This is applicable to item views that containsubviews or controls. For item views that are just images, it's better to usethe approach shown in theDynamic ImageEffectsexample.
DynamicImageEffects
This exampledemonstrates how to use the FXImageView class(https://github.com/nicklockwood/FXImageView) to dynamically generatereflections and drop shadows for your carousel images.
DynamicDownloads
This exampledemonstrates how to use the AsyncImageView class(https://github.com/nicklockwood/AsyncImageView) to dynamically download remoteimages and display them in a carousel without blocking the main thread ornegatively affecting performance.
Downloads&Effects
This exampledemonstrates how to use the FXImageView class(https://github.com/nicklockwood/FXImageView) to download images on the fly andapply reflections and drop shadows to them in real time.
FAQ
Q.I upgrade to thenewversion of iCarouselandit brokemyproject,howdoIgetthe old one back?
A.Everyprevious release of iCarouselistaggedasa separatedownload on github-lookinthe tags tab.
Q.CanIuseiCarousel without a nib file?
A.Yes,checkoutthe*NoNibDemo*forhow tosetup iCarousel without nibs
Q.CanIuseiCarouselwithaStoryboard?
A.Yes,thisispretty much thesameasusingitwitha nib file.Checkoutthe*StoryboardDemo*to see how it's done.
Q. How do Iprevent iCarousel item views from overflowing their bounds?
A. Set the`clipsToBounds` property to YES on your iCarousel view. You can set thisproperty in Interface Builder by ticking the 'ClipSubviews' option.
Q. I'm gettingweird issueswhereviews turn up at the wrong pointsinthe carousel.What's going on?
A. You'reprobably recycling viewsinyour`carousel:viewForItemAtIndex:reusingView:`usingthe`reusingView`parameter without setting the view contentseach time.Studythe demo app more closelyandmake sure you aren't doing all your itemview setup in the wrong place.
Q. I'm loading50imagesinmycarouselandI keep runningoutof memory.Howcan I fix it?
A.Thetrickisto load the viewson a background threadasthe carouselisscrolling instead of loading them allinadvance.Checkoutthe*DynamicDownloads*exampleforhow todothisusingtheAsyncImageViewlibrary.Theexampleisusingremote imageURLs,but the exact same approach will work justaswellforlocally hosted imagesinyour app-just createlocalfileURLsusing`[NSURL fileUrlWithPath:...]`.
Q.CanIusemultiple carouselsinthe same viewcontroller?
A.Yes,checkoutthe*MultipleCarousels*exampleforhow todothis.
Q.I can't figure out how to use iCarousel inmy project, is there a simple example?
A. Yes, check outthe *Basic iOS Example* project for a bare-bones implementation. If you'restillnotclear what's going on, read up about howUITableView works, and once you understand that, iCarousel will make moresense.
Q. In theiCarouselTypeCylinder carousel, the back-side of the item views is visible. Howcan I hide these views?
A. You can eitherreturn NO as the value for the `iCarouselOptionShowBackfaces` option, or setthe `view.layer.doubleSided` property of your item views to `NO` to hide themwhen they are facing backwards.
Q. What is the`reusingView` property for in the `carousel:viewForItemAtIndex:reusingView:`dataSource method?
A. You canimprove iCarousel performance by recycling item views when they move offscreeninstead of creating a new one each time it's needed.Checkifthisvalueisnil,andifnotyou can re-usethisview instead of creating anewone.Notehowever that the view will still haveany subviewsorproperties you addedwhenit was first created,so be carefulnotto introduce leaksbyre-adding thoseviews each time.Youmay find it's easier and safer to ignorethis paramater and create a fresh view each time if you'renotsure what you are doing.
Q.Ifthe viewsinmycarousel all have completely differentlayouts,should I stillusethe`reusingView`parameter?
A.Probablynot,andunlessyou have hundreds of viewsinyour carousel,it's unlikely to be worth the trouble.
Q. I'musingiCarouselTypeLinear.Howcan I make it behave more like aUIScrollViewwithpaging enabled?
A.IfyousetdecelerationRate to zerotheniCarousel will more closely emulate thefeel of aUIScrollView.Ifthat's still notclose enough, consider using my SwipeView library instead(https://github.com/nicklockwood/SwipeView) which is very similar to iCarousel,but based on a UIScrollView.
Q. I want mycarousel items to have a real reflection, but the reflection in the examples isjust drawn on. How can I render reflections dynamically?
A. iCarouseldoesn't have built-inreflectionsupport,but you canusesome additional libraries todothis.Checkoutthe*DynamicViewReflections*and*DynamicImageEffects*examples.
Q.I want to download a bunch of images on theflyanddisplay theminmycarousel.Howcan Idothat?
A.Downloadingimages asynchronouslyanddisplaying themisquite complex.YoucanusemyAsyncImageViewlibrary to simplify the process.Checkoutthe*DynamicDownloads*example.
Q.WhatifI want todownload images on the fly*and*add a reflection?CanI combine theReflectionViewandAsyncImageViewclasses?
A.Technicallyyes,butifyou aredownloading images you'd be better off using the FXImageView class instead ofReflectionView. Check out the *Downloads & Reflections* example.
Q. The edges ofmy item views look jaggy. Is there any way to smooth/antialias them?
A. If you include(at least) a single pixel of transparent space around the edge of your itemview images then iOS will smooth them automatically. This is because iOSautomatically antialiases the pixels inside images, but doesn't antialias theedges of views.Evenifyour item viewsare a flat color,it's worth addinga background image of the same color to the views in order to get the smoothingeffect.
原文地址: https://www.binpress.com/app/icarousel/614