可用于水平滚动的视图,具有特定的内容宽度。
UICarouselScrollView可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中
pod "UICarouselScrollView"
然后执行
$ pod install
@required
- (UIView *)carouselScrollView:(UICarouselScrollView *)view viewAtPage:(NSInteger)page;
@optional
- (void)carouselScrollView:(UICarouselScrollView *)view clickedAtPage:(NSInteger)page;
- (NSString *)carouselScrollView:(UICarouselScrollView *)view titleAtPage:(NSInteger)page;
- (NSString *)carouselScrollView:(UICarouselScrollView *)view subTitleAtPage:(NSInteger)page;
[self.nibView setDelegate:self];
[self.nibView setSlideTime:3];
[self.nibView setShouldDetectNextAndPreviousClickEvent:NO];
[self.nibView setGradientColors:@[(id)[[UIColor blackColor] colorWithAlphaComponent:0].CGColor,(id)[[UIColor blackColor] colorWithAlphaComponent:0.6].CGColor]];
carouselView = [[UICarouselScrollView alloc] initWithFrame:CGRectMake(10, 300, 260, 180)];
[self.view addSubview:carouselView];
[carouselView setDelegate:self];
[carouselView setMaxWidth:200];
[carouselView setSlideTime:2];
[carouselView setShouldDetectNextAndPreviousClickEvent:NO];
[carouselView setGradientColors:@[(id)[[UIColor blackColor] colorWithAlphaComponent:0].CGColor,(id)[[UIColor blackColor] colorWithAlphaComponent:0.6].CGColor]];
@property (nonatomic, assign) NSInteger numberOfPage; //trigger
@property (nonatomic, assign) NSInteger cacheCount; //default = 2 (previous&next pages)
@property (nonatomic, assign) float slideTime; //if 0, don't auto slide
@property (nonatomic, assign) float maxWidth; //if 0, view size
@property (nonatomic, assign) BOOL shouldDetectNextAndPreviousClickEvent;
skswhwo, [email protected]
UICarouselScrollView遵守MIT许可证。有关更多信息,请参阅LICENSE文件。