第三方库
//第一种:iCarousel(多种类型)需要关闭ARC
- (void)viewDidLoad {
[super viewDidLoad];
//导入需要的第三方库中的iCarousel.h头文件
//创建对象
carousel = [[iCarousel alloc]initWithFrame:self.view.bounds];
//设置数据源和代理实现两个协议方法
carousel.delegate = self;
carousel.dataSource = self;
[self.view addSubview:carousel];
}
//切换按钮的绑定方法
- (void)ButtonTouched {
//获取type枚举类型可用数字代替
inttype = carousel.type;
//用三目运算法判断==必须的
type = (type == iCarouselTypeCoverFlow2) ? iCarouselTypeLinear : (type + 1) ;
//赋值type
carousel.type = type;
}
#pragma mark --- iCarouselDataSource, iCarouselDelegate
//返回有多少个展示项
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel {
return 9;
}
//返回展示视图
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index {
UIImageView *showImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
showImage.image= [UIImage imageNamed:[NSString stringWithFormat:@"%ld.jpg",index+1]];
return showImage;
}
//第二种:OpenFlow(一种类型)需要关闭ARC
- (void)viewDidLoad {
[super viewDidLoad];
//导入需要的第三方库中的AFOpenFlowView.h头文件
//创建对象
AFOpenFlowView *ofView = [[AFOpenFlowView alloc] initWithFrame:self.view.bounds];
//设置数据源
ofView.dataSource = self;
//设置展示页数
ofView.numberOfImages = 9;
//指定默认图片
[ofView setDefaultImage:[UIImage imageNamed:@"1.jpg"]];
[self.view addSubview:ofView];
}
#pragma mark --- AFOpenFlowViewDataSource, AFOpenFlowViewDelegate
- (void)openFlowView:(AFOpenFlowView *)openFlowView requestImageForIndex:(int)index {
openFlowView.defaultImage = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",index + 1]];
}
- (UIImage *)defaultImage {
return [UIImage imageNamed:@"1.jpg"];
}