ios - 时间轴效果的实现
ringa_lee
ringa_lee 2017-04-17 14:26:32
[iOS讨论组]

这是我的效果:

这是我要达到的效果:

我的代码:

  CGFloat circularLabelWidth = 10;
        UILabel *circularLabel = [[UILabel alloc] initWithFrame:CGRectMake(CELL_HEIGHT_FOOT_LEFTX/2 - circularLabelWidth/2, Height_Section_Header/2 - circularLabelWidth/2, circularLabelWidth, circularLabelWidth)];
        circularLabel.backgroundColor = self.footPrintTableView.backgroundColor;
        circularLabel.layer.cornerRadius = circularLabelWidth/2;
        circularLabel.layer.masksToBounds = YES;
        circularLabel.layer.borderColor = [UIColor whiteColor].CGColor;
        circularLabel.layer.borderWidth = circularLabelWidth/4;
        [headerLabel addSubview:circularLabel];

主要是他那个圆环,我不知道怎么折腾了。有给点提示吗?

ringa_lee
ringa_lee

ringa_lee

全部回复(1)
巴扎黑

构思一下

1个正方形方块+1个圆环

开始

假设cell的背景色为#define CELLBGCOLOR [UIColor colorwith......]

//1.实现方块,定义方块的长=15 高=15 构造一个透明假象

UIView *sqView = [[UIView alloc] initWithFrame:CGRectMake(CELL_HEIGHT_FOOT_LEFTX/2 - 15/2, Height_Section_Header/2 - 15/2, 15, 15)];
sqView.backgroundColor = CELLBGCOLOR;//这里就是为了让其和cell的背景一致啦

[headerLabel addSubview:sqView];

//2.添加你的圆环,如何剧中,自己处理下把

        CGFloat circularLabelWidth = 10;
        UILabel *circularLabel = [[UILabel alloc] initWithFrame:CGRectMake(2.5, 2.5, circularLabelWidth, circularLabelWidth)];
        circularLabel.backgroundColor = self.footPrintTableView.backgroundColor;
        circularLabel.layer.cornerRadius = circularLabelWidth/2;
        circularLabel.layer.masksToBounds = YES;
        circularLabel.layer.borderColor = [UIColor whiteColor].CGColor;
        circularLabel.layer.borderWidth = circularLabelWidth/4;

[sqView addSubview:circularLabel];

再简单一点?

直接用图片替换,简单吗?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号