zoukankan      html  css  js  c++  java
  • CALayer 绘制边框线不能被遮挡

    一般我们在布局视图时遵从一个原则: 后加的先显示。

    下面简述下我遇到的问题:图片未能盖住背景视图的边框,边框使用的是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来说,必须是在同一个等级

  • 相关阅读:
    写一个列表生成式,产生一个公差为11的等差数列
    如果对方网站反爬取,封IP了怎么办?
    为什么会选择redis数据库?
    你是否了解谷歌的无头浏览器?
    遇到的反爬虫策略以及解决方法?
    常见的HTTP方法有哪些?
    遇到反爬机制怎么处理?
    列举网络爬虫所用到的网络数据包,解析包?
    python中的关键字yield有什么作用?
    如下代码输出的是什么?
  • 原文地址:https://www.cnblogs.com/lijianyi/p/11904236.html
Copyright © 2011-2022 走看看