轮播图 SDCycleScrollView

//布局轮播图

- (void)layoutHeaderView

{

    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width * 0.6)];

    self.tableView.tableHeaderView.backgroundColor = [UIColor orangeColor];

    

    // 情景:采用网络图片实现

    NSArray *imagesURLStrings= _strArray;

    

    // 情景:图片配文字

    NSArray *titles = _titleArray;

    

    width = [UIScreen mainScreen].bounds.size.width;


    //网络加载 --- 创建带标题的图片轮播器

    SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, width, self.tableView.tableHeaderView.frame.size.height) imageURLStringsGroup:nil]; // 模拟网络延时情景

    cycleScrollView2.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;

    cycleScrollView2.delegate = self;

    cycleScrollView2.titlesGroup = titles;

    cycleScrollView2.dotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色

    cycleScrollView2.placeholderImage = [UIImage imageNamed:@"left.png"];

    [self.tableView.tableHeaderView addSubview:cycleScrollView2];

    

    //--- 模拟加载延迟

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        cycleScrollView2.imageURLStringsGroup = imagesURLStrings;

    });

        

}


//点击轮播图图片进入详情

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index

{

    HomeModel *model = self.homeModelArray[index];

    DetailViewController *detailVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"detail"];

    detailVC.myID = model.dishes_id;

    detailVC.myTitle = model.title;

    detailVC.homeModel = model;

    [self.navigationController pushViewController:detailVC animated:YES];

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值