楼主项目中需要有一个轮播图,因为比较简单,就自己写了个,因为是从网上弄得图片 所以用了SDWebImage 这个三方库 当然自己也可以去掉
类型后面有*号 如用使用 请自行加上。。。。。
代码:.h 文件
@protocol TJXViewDelegate
//判断点击的那个
-(void)sendImageName:(TJXView *)TJXView andName:(NSInteger)selectImage;
@end
@interface TJXView : UIView
@property (nonatomic,weak)iddelegate;
//传一个frame 和 装有图片名字的数组过来
//参数一:frame
//参数二:装有图片名字的数组
//参数三:BOOL如果是YES,那么自动滚动,如果是NO不滚动
-(id)initWithFrame:(CGRect)frame andImageNameArray:
(NSMutableArray * )imageNameArray andIsRunning:(BOOL)isRunning;
@end
.m文件
@interface TJXView()
{
NSInteger _currentPage; //记录真实的页码数
NSTimer *_timer; //生命一个全局变量
}
@property (nonatomic,assign) BOOL isRun;
@property (nonatomic,strong) NSMutableArray *imageArray;//存储图片的名字
@property (nonatomic,strong) UIScrollView *scrollView;
@property (nonatomic,strong) UIPageControl *pageControl;
@property (nonatomic,assign) CGFloat width;//view的宽
@property (nonatomic,assign) CGFloat height;//view的高
@end
-(id)initWithFrame:(CGRect)frame andImageNameArray:(NSMutableArray *)imageNameArray andIsRunning:(BOOL)isRunning{
self = [super initWithFrame:frame];
if