iOS 轮播视图简洁版

先来看看效果吧。


此轮播是基于UIScrollView实现的,写得比较简洁,具体代码逻辑可参考代码。上Demo
######简单实现思路
1.使用到了模型数组,从而提高了代码的可扩展性。
2.UIScrollView +UIPageControl +UIImageView+UILabel(可添加多个)
3. UIPageControl、UILabel位置可任意调整提供了pageFrame、titleFrame调整位置
4. 可设置自动滚动和不滚动(removeTime)
5.简单的网络图片下载类封装管理工具。


使用规则

//图片模型数组
    NSMutableArray *imageUrls = [NSMutableArray array];
    JHShufflingModel *model1 = [[JHShufflingModel alloc]init];
    model1.title1 = @"妹子1";
    model1.title1Color = [UIColor redColor];
    model1.title2 = @"妹子1的副标题";
    model1.title2Color = [UIColor greenColor];
    model1.imageUrl = @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595326302959&di=849856fde4e129cff3cbe2ac71eb4a35&imgtype=0&src=http%3A%2F%2F00.minipic.eastday.com%2F20170420%2F20170420105628_ea6da92abc46098d8e03ad2ee55abeb7_9.jpeg";

    CGFloat bili = 1024.0/1536.0;
    int width = 480*bili;//转整数,宽度不能有小数点位,
//    添加自动轮播器
    JHShufflingView *shufflingView = [[JHShufflingView alloc]initWithFrame:CGRectMake(15, 120, width, 480)];
    shufflingView.delegate = self;
    [self.view addSubview:shufflingView];
    shufflingView.contentMode = UIViewContentModeScaleToFill;//设置图片显示模式
    shufflingView.title1Frame = CGRectMake(0, 0, shufflingView.frame.size.width, 20);//设置标题1的frame
    shufflingView.title2Frame = CGRectMake(0, 30, shufflingView.frame.size.width, 20);//设置标题2的frame
    shufflingView.pageHidden = YES;//隐藏page
    shufflingView.pageColor = [UIColor redColor];//设置未选中page圆点颜色
    shufflingView.currentPageColor = [UIColor yellowColor];//设置选中page圆点颜色
    [shufflingView setingPageImage:@"shuanglingxing" andCurrentPageImage:@"shuanglingxingSel"];//设置page选中与未选中图片

    shufflingView.timeInterval = 2;//设置定时器时间间隔,不设置默认3秒
    
    shufflingView.urlImageArray = imageUrls;//设置图片数组

原文地址:https://www.jianshu.com/p/81571b8da365

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值