美文网首页
部分圆角+边框

部分圆角+边框

作者: 芝麻绿豆 | 来源:发表于2020-08-27 11:31 被阅读0次
- (void)setborderCornerRadius:(CGFloat)cornerRadius type:(UIRectCorner)corners lineWidth:(CGFloat)lineWidth  borderColor:(UIColor *)borderColor{
    CGSize radii = CGSizeMake(cornerRadius, cornerRadius);
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:radii];
    CAShapeLayer *maskLayer   = [CAShapeLayer layer];
    maskLayer.frame           = self.bounds;
    maskLayer.path            = path.CGPath;
    self.layer.mask           = maskLayer; //  必须添加 不然会出现边框粗细不对
    
    CAShapeLayer *shapeLayer    = [CAShapeLayer layer];
    shapeLayer.frame            = self.bounds;
    shapeLayer.path             = path.CGPath;
    shapeLayer.lineWidth        = lineWidth;
    shapeLayer.lineCap          = kCALineCapSquare;
    shapeLayer.fillColor        = [UIColor clearColor].CGColor;
    shapeLayer.strokeColor      = borderColor.CGColor;
    [self.layer addSublayer: shapeLayer];
}
layer.mask省略会出现边框粗细不对!

相关文章

  • 部分圆角+边框

    layer.mask省略会出现边框粗细不对!

  • CSS边框圆角--跟着李南江学编程

    1.什么是边框圆角? 就是把矩形边框变成圆角边框,就叫做边框圆角。 2.设置边框圆角的格式 2.1 border-...

  • 25.边框圆角渐变

    边框 什么是边框圆角?将直角的边框变为圆角的边框 边框圆角的格式?border-radius: 左上 右上 右下 ...

  • Flutter-Border

    边框(Border) 单侧边框 全部边框 圆角(borderRadius) 全部圆角 单侧圆角 阴影(BoxSha...

  • Image

    直接圆角图片 设置圆角图片度数 设置圆角图片带灰色圆角边框 设置圆角图片带灰色圆角边框带阴影

  • 常用CSS3 一目了然

    1.css3边框 圆角边框 border-radius: 5px;(圆角半径) 边框阴影 box-shadow: ...

  • android中实现view的圆角

    一、实心圆角 二、空心圆角、有边框

  • UIView任意角圆角和圆角边框

    圆角原理:设置view.layer.mask该遮罩层。 圆角边框:在view.layer 上增加一层,绘制圆角边框...

  • CSS3边框,背景,渐变,过渡,2d变换

    01-边框圆角.html 02-圆角应用.html 03-边框阴影.html 04-边框图片.html 01-背景...

  • 盒模型

    内容区 内边距 边框 指定边框圆角 边框风格 外边距

网友评论

      本文标题:部分圆角+边框

      本文链接:https://www.haomeiwen.com/subject/omlcsktx.html