XMRotationChartView
使用方式 #import “XMRotationChartView.h”
继承XMRotationChartViewDelegate
@interface UIViewController ()<XMRotationChartViewDelegate>
@property (nonatomic,strong) NSMutableArray<NSString *> *imageUrl;
@end
XMRotationChartView *view = [[XMRotationChartView alloc] initWithFrame:CGRectMake(400, 300, 300, 300)];
self.imageUrl = [@[@"img1.png",@"img2.png",@"img3.png"] mutableCopy];
view.delegate = self;
[view setRotationChartDirection:XMRotationChartDirectionLeft];
[self.view addSubview:view];
代理方法(必须重写的)
- (NSInteger)rotationChartCount:(XMRotationChartView *)RotationChart{
return self.imageUrl.count;
}
- (UIImageView *)rotationChartAtIndex:(XMRotationChartView *)RotationChart atIndex:(NSInteger)index{
UIImageView *imageView =[[UIImageView alloc] init];
[imageView setImage:[UIImage imageNamed:[self.imageUrl objectAtIndex:index]]];
[imageView setContentMode:UIViewContentModeScaleAspectFit];
return imageView;
}
代理方法(扩展功能)
- (BOOL)isAutoCarousel:(XMRotationChartView *)RotationChart{
return YES;
}
- (NSTimeInterval)rotationChartSpeed:(XMRotationChartView *)RotationChart{
return 0.5;
}
- (NSTimeInterval)IntervalInSeconds:(XMRotationChartView *)RotationChart{
return 2.0;
}
- (UIColor *) rotationChartTintColor:(XMRotationChartView *)RotationChart{
return [UIColor redColor];
}
- (void)rotationChartCurrentIndex:(XMRotationChartView *)RotationChart currentIndex:(NSInteger)index{
NSLog(@"当前下标:%ld",index);
}
- (void)didSelectedRotationChartCurrentIndex:(XMRotationChartView *)RotationChart currentIndex:(NSInteger)index{
NSLog(@"点击选择当前下标:%ld",index);
}