iCarousel详解
Posted u010850094
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iCarousel详解相关的知识,希望对你有一定的参考价值。
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, add USING_CHAMELEONto your project‘s preprocessor macros.Check out the Chameleon Demo example 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 using iCarouselTypeCustom and thecarousel:itemTransformForOffset:baseTransform: delegate method.
你也可以使用iCarouselTypeCustom和carousel:itemTransformForOffset:baseTransform:代理方法来实现自己的定制carousel样式
NOTE: Thedifference between iCarouselTypeCoverFlow and iCarouselTypeCoverFlow2 types is quite subtle, however the logic for iCarouselTypeCoverFlow2 is 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. iCarouselTypeCoverFlow2 is 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) IBOutlet id dataSource;
An object thatsupports the iCarouselDataSource protocol and can provide views to populate thecarousel.
一个支持iCarouselDataSource协议且能提供视图来填充carousel的对象。
@property (nonatomic, weak) IBOutlet id delegate;
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) CGFloat perspective;
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) CGSize contentOffset;
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 items without changing theirperspective, i.e. the vanishing point moves with the carousel items, so if youmove the carousel items down, it does not appear 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) CGSize viewpointOffset;
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) CGFloat decelerationRate;
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) CGFloat bounceDistance;
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 the carousel:valueForOption:withDefault: delegate method and return a value for iCarouselOptionWrap.
如果打包被使能的话,返回yes,如果不是返回no。这个属性是只读的。如果你想重写这个默认值,实现carousel:valueForOption:withDefault:方法且给iCarouselOptionWrap返回一个值。
@property (nonatomic, readonly) NSInteger numberOfItems;
The number of itemsin the carousel (read only). To set this, implement the numberOfItemsInCarousel: 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) NSInteger numberOfPlaceholders;
The number ofplaceholder views to display in the carousel (read only). To set this,implement thenumberOfPlaceholdersInCarousel: dataSource method.
在carousel中展示的占位视图的数量(只读)。要设置他,实现一下numberOfPlaceholdersInCarousel:这个数据源方法。
@property (nonatomic, readonly) NSInteger numberOfVisibleItems;
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 to numberOfItems. Indexes forplaceholder views in this array do not equate 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 the indexOfItemView: 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.
包含carousel item views的视图。你可以增加子视图如果你想用这些carousel items散置这些视图。如果你想让一个视图出现在所有carouselitems的前边或者后边,你应该直接添加它到iCarousel view本身来替代。注意,在contentView中视图的顺序是受当app执行时的频率和未标注的变化决定的。任何添加到contentView中的视图应该将他们的 userInteractionEnabled属性设置为no来防止和iCarousel的触摸时间处理放生冲突。
@property (nonatomic, assign) CGFloat scrollOffset;
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) CGFloat offsetMultiplier;
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) NSInteger currentItemIndex;
The index of thecurrently centered item in the carousel. Setting this property is equivalent tocalling scrollToItemAtIndex: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 matches currentItemIndex.
当前carousel中居中的item view。这个视图的索引与currentItemIndex匹配。
@property (nonatomic, readonly) CGFloat itemWidth;
The display widthof items in the carousel (read only). This is derived automatically from thefirst view passed in to the carousel using the carousel:viewForItemAtIndex:reusingView:dataSource method.You can also override this value using the carouselItemWidth: 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) CGFloat scrollSpeed;
This is the scrollspeed multiplier when the user flicks the carousel with their finger. Defaultsto 1.0.
这是当用户用手指轻击carousel时 滚动速度乘数。默认值是1.0.
@property (nonatomic, readonly) CGFloat toggle(切换键);
This property isused for the iCarouselTypeCoverFlow2 carousel 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 and bounces is 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上,使用的却是CVDisplayLink API。这个在屏幕刷新时提供了更好的同步效果,但是当 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 as scrollToItemAtIndex:, but allows you toscroll to a fractional offset. This may be useful if you wish to achieve a veryprecise animation effect. Note that if the scrollToItemBoundary property 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 as scrollByNumberOfItems:, 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 the scrollToItemBoundary property is set to YES, the carousel will automatically scroll to thenearest item index after you call this method anyway.
这个方法作用与scrollByNumberOfItems:方法一样,但是允许你滚动到一个微小数量的items。如果你想达到一个非常准确的动 以上是关于iCarousel详解的主要内容,如果未能解决你的问题,请参考以下文章