Contents
  1. 1. RYImagesScroller_iOS高度自定义的图片轮播器
    1. 1.1. 图片轮播
    2. 1.2. 混合轮播实现思路
    3. 1.3. 效果展示
      1. 1.3.1. 方法:

RYImagesScroller_iOS高度自定义的图片轮播器

之前在项目中遇到了需要图片和视频混合轮播的需求
但是没找到合适的轮播器于是就自己撸了一个

项目地址: https://github.com/RyukieSama/RYImagesScroller

图片轮播

支持自定义分页图片
支持自定义蒙版视图

混合轮播实现思路

外部传入自定义View数组 和 各个自定义View对应的index数组即可
传入的View会被覆盖在对应的Cell上面

效果展示

IMG_1675
IMG_1676

上图效果示例代码:
上图在第一个和第三个添加了一个开关和滑动条

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
_svImages = [[RYImagesScrollView alloc] initWithFrame:CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*3/7) pageStyle:RYImageScrollerPageStyleCustom];
_svImages.autoScrollTimeInterval = 4.0f;
_svImages.contentMode = UIViewContentModeScaleAspectFill;
_svImages.normalPageImage = [UIImage imageNamed:@"outdoor_icon_carousel"];
_svImages.currentPageImage = [UIImage imageNamed:@"outdoor_icon_carousel_selected"];
self.svImages.imageURLs = @[
@"http://cc.cocimg.com/api/uploads/20170407/1491531818350790.png",
@"http://cc.cocimg.com/api/uploads/20170407/1491531897388821.png",
@"http://cc.cocimg.com/api/uploads/20170407/1491531754597727.png",
@"http://cc.cocimg.com/api/uploads/20170407/1491531459990792.png",
@"http://cc.cocimg.com/api/uploads/20170407/1491531504501824.jpg"
];
//这里的意思是在第一页和第三页 添加自定义蒙版视图
self.svImages.attachIndexArr = @[
@0,
@2
];
//这里的意思是在第一页和第三页的 添加自定义蒙版视图数组 蒙版会自适应轮播控件的大小 如果需要自定义位置 最好用一个背景透明的容器装下
self.svImages.attachViewArr = @[
[[UISwitch alloc] init],
[[UISlider alloc] init]
];

方法:

初始化:

1
2
3
4
5
6
/**
初始化方法 并设置分页样式
@param style 分页样式
*/
- (instancetype)initWithFrame:(CGRect)frame pageStyle:(RYImageScrollerPageStyle)style;

分页样式

1
2
3
4
5
6
7
8
9
10
typedef NS_ENUM(NSInteger, RYImageScrollerPageStyle) {
/**
系统分页样式
*/
RYImageScrollerPageStyleNormal = 99,
/**
用户自定义分页样式
*/
RYImageScrollerPageStyleCustom = 100
};

其他参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* 图片数组
*/
@property (nonatomic, strong) NSArray <NSString *> *imageURLs;
/**
* 需要添加辅助view的序号数组 与 attachViewArr 一一对应
*/
@property (nonatomic, strong) NSArray <NSNumber *> *attachIndexArr;
/**
* 辅助View数组
*/
@property (nonatomic, strong) NSArray <UIView *> *attachViewArr;
/**
* 滚动时间间隔 默认2s
*/
@property (nonatomic, assign) CGFloat autoScrollTimeInterval;
/**
* 默认 UIViewContentModeScaleAspectFill
*/
@property (nonatomic, assign) UIViewContentMode contentMode;
/**
非当前展示页的分页图片 仅在 RYImageScrollerPageStyleCustom 下生效
*/
@property (nonatomic, strong) UIImage *normalPageImage;
/**
当前页的分页图片 仅在 RYImageScrollerPageStyleCustom 下生效
*/
@property (nonatomic, strong) UIImage *currentPageImage;
/**
* 点击图片的回调
*/
@property (nonatomic, copy) ImageScrollHandler handler_imageClick;
/**
* 每次滚动完的回调
*/
@property (nonatomic, copy) ImageScrollHandler handler_scrollCallBack;
Contents
  1. 1. RYImagesScroller_iOS高度自定义的图片轮播器
    1. 1.1. 图片轮播
    2. 1.2. 混合轮播实现思路
    3. 1.3. 效果展示
      1. 1.3.1. 方法: