博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
新浪微博客户端(11)-自定义checkBox
阅读量:5930 次
发布时间:2019-06-19

本文共 2130 字,大约阅读时间需要 7 分钟。

 

在最后一个欢迎界面上添加一个CheckBox.

// 2.添加4个UIImageView    for (int i = 0; i < NEW_FEATURE_NUMS; i++) {       UIImageView *imageView = [[UIImageView alloc] init];        imageView.size = scrollView.size;        imageView.y = 0;        imageView.x = i * scrollW;        NSString *imageName = [NSString stringWithFormat:@"new_feature_%d",i+1];        imageView.image = [UIImage imageNamed:imageName];        [scrollView addSubview:imageView];                // 如果是最后一张图片,则添加进入按钮        if (i == NEW_FEATURE_NUMS - 1) {            [self setupEnterBtn:imageView];        }            }

 

/** 添加分享checkbox及进入微博按钮 */- (void)setupEnterBtn:(UIImageView *)imageView {    // 0.设置imageView可以交互    imageView.userInteractionEnabled = YES;        // 1.添加shareBtn    UIButton *shareBtn = [[UIButton alloc] init];    [shareBtn setImage:[UIImage imageNamed:@"checkbox_unchecked"] forState:UIControlStateNormal];    [shareBtn setImage:[UIImage imageNamed:@"checkbox_checked"] forState:UIControlStateSelected];        [shareBtn setTitle:@"分享到微博" forState:UIControlStateNormal];    [shareBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];    shareBtn.titleLabel.font = [UIFont systemFontOfSize:14];    shareBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 16, 0, 0);    shareBtn.width = 200;    shareBtn.height = 44;    shareBtn.centerX = imageView.width * 0.5;    shareBtn.centerY = imageView.height * 0.75;    [shareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];        [imageView addSubview:shareBtn];            // 2.添加进入微博按钮    UIButton *enterBtn = [[UIButton alloc] init];    [enterBtn setBackgroundImage:[UIImage imageNamed:@"new_feature_button"] forState:UIControlStateNormal];    [enterBtn setBackgroundImage:[UIImage imageNamed:@"new_feature_button_highlighted"] forState:UIControlStateHighlighted];    enterBtn.size = enterBtn.currentBackgroundImage.size;    enterBtn.centerX = shareBtn.centerX;    enterBtn.centerY = imageView.height * 0.82;    [imageView addSubview:enterBtn];    }- (void)shareBtnClick:(UIButton *)btn {    btn.selected = !btn.isSelected;        DJLog(@"fdfd");}

 

最终效果:

 

转载地址:http://vbutx.baihongyu.com/

你可能感兴趣的文章
C#串口通信实例
查看>>
TCP协议三次握手过程分析
查看>>
蓝桥杯 兰顿蚂蚁(Bfs)
查看>>
杭电1234--开门人和关门人
查看>>
杭电2029--Palindromes _easy version(回文串)
查看>>
redis的hash, list, set类型相关命令
查看>>
文件流之字节缓冲流(BufferedInputStream BufferedOutputStream)
查看>>
聪明的燕姿[JLOI2014]
查看>>
天鹅会面
查看>>
一个非科班出身程序员的成长历程
查看>>
图解Raid5数据存储的原理
查看>>
TensorFlow NormLization
查看>>
KVM克隆CentOS6虚拟机后无法启动
查看>>
【leetcode】982. Triples with Bitwise AND Equal To Zero
查看>>
虚拟机和本机配置共享文件夹
查看>>
c++异常处理
查看>>
哎呀妈呀,吓死我了,幸好服务器没崩溃。
查看>>
第一次作业-准备篇
查看>>
RunLoop基础
查看>>
移动浏览器的四大内核
查看>>