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 th
e 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
变⾊龙⽀持
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 thedif
ference 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 ne
gative 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时,这个属性不起作⽤。
datasource是什么意思@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 c
arousel 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返回⼀个值。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论