CALayer 绘制边框线不能被遮挡
发布日期:2022-04-05 00:52:15
浏览次数:4
分类:博客文章
本文共 1884 字,大约阅读时间需要 6 分钟。
一般我们在布局视图时遵从一个原则: 后加的先显示。
下面简述下我遇到的问题:图片未能盖住背景视图的边框,边框使用的是CALayer绘制,但其余部分都能遮盖住,难道CALayer不能被遮挡?
实现代码如下:
self.bgView = [[UIView alloc]init]; self.bgView.layer.cornerRadius = 5.0; [self.bgView borderWidth:1 andBorderColor:CC_ICOME(@"#B8D2FF6B")]; self.bgView.backgroundColor = CC_ICOME(@"F8FBFF8F"); [self.contentView addSubview:self.bgView]; [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView.mas_top); make.left.equalTo(self.contentView.mas_left).offset(10); make.right.equalTo(self.contentView.mas_right).offset(-10); make.bottom.equalTo(self.moreImage.mas_top); }]; [self.bgView addSubview:self.leftImage]; [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgView).offset(-2); make.top.equalTo(self.bgView.mas_top).offset(9); make.height.mas_equalTo(22); make.width.mas_equalTo(6); }];
先看修改后效果:线被完美遮当
实现代码如下:
self.bgView = [[UIView alloc]init]; self.bgView.layer.cornerRadius = 5.0; [self.bgView borderWidth:1 andBorderColor:CC_ICOME(@"#B8D2FF6B")]; self.bgView.backgroundColor = CC_ICOME(@"F8FBFF8F"); [self.contentView addSubview:self.bgView]; [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView.mas_top); make.left.equalTo(self.contentView.mas_left).offset(10); make.right.equalTo(self.contentView.mas_right).offset(-10); make.bottom.equalTo(self.moreImage.mas_top); }]; [self.contentView addSubview:self.leftImage]; [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgView).offset(-2); make.top.equalTo(self.bgView.mas_top).offset(9); make.height.mas_equalTo(22); make.width.mas_equalTo(6); }];
综上所述:后加的先显示,针对CALayer来说,必须是在同一个等级
转载地址:https://www.cnblogs.com/lijianyi/p/11904236.html 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月24日 20时03分16秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Lua(十六)——文件
2019-04-27
Lua(十七)——面向对象
2019-04-27
Lua(十八)——错误处理,垃圾回收
2019-04-27
xLua(一)——介绍
2019-04-27
xLua(二)——下载
2019-04-27
Unity中实现解析Json文件
2019-04-27
Unity自带Json解析库——JsonUtility
2019-04-27
Unity中使用ViedoPlayer操作视频文件
2019-04-27
背景+带边框(圆角)的textview怎么设置
2019-04-27
第二技能
2019-04-27
算法的设计
2019-04-27
JAVA Freemarker(9)---常见语法大全
2019-04-27
Java MyBatis(1)--- Generator 详解
2019-04-27
Java MyBatis(2)--- generatorConfig.xml详解与运行
2019-04-27
VueJS(5)---初步练习(5题)
2019-04-27
mysql(3)-- 修改root密码命令小结
2019-04-27
JQuery(3)--冒泡效果
2019-04-27
异常(2)-- UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/项目包名
2019-04-27
Android软键盘(1)---输入法界面管理(打开/关闭/状态获取)
2019-04-27
Android动态设置view的高度宽度
2019-04-27