美文网首页
2020-09-25

2020-09-25

作者: 驰马奥 | 来源:发表于2020-09-25 00:43 被阅读0次

随笔

uiview 绘制圆角

方法一

    CAShapeLayer *shapeLayer = [CAShapeLayer layer];

   UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];

    shapeLayer.path= path.CGPath;

    self.layer.mask= shapeLayer;

方法二

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];

    CAShapeLayer*maskLayer = [[CAShapeLayeralloc]init];

    maskLayer.frame=self.bounds;

    maskLayer.path= maskPath.CGPath;

    self.layer.mask= maskLayer;

方法三

    CAShapeLayer *maskLayer = [CAShapeLayer layer];

    maskLayer.frame=self.bounds;

    CAShapeLayer*borderLayer = [CAShapeLayerlayer];

    borderLayer.frame=self.bounds;

    borderLayer.lineWidth= borderWidth;

    borderLayer.strokeColor= borderColor.CGColor;

    borderLayer.fillColor = [UIColor clearColor].CGColor;

    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius];

    maskLayer.path= bezierPath.CGPath;

    borderLayer.path= bezierPath.CGPath;

    [self.layer insertSublayer:borderLayer atIndex:0];

    [self.layersetMask:maskLayer];

方法四

    CAShapeLayer *layer = [[CAShapeLayer alloc] init];

    CGMutablePathRef pathRef = CGPathCreateMutable();

    CGRectbounds =CGRectInset(self.frame,0,0);

    CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));

    CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), cornerRadius);

    CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMinY(bounds), cornerRadius);

    CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMinX(bounds), CGRectGetMinY(bounds), cornerRadius);

    CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMinX(bounds), CGRectGetMaxY(bounds), cornerRadius);

    layer.path= pathRef;

    CFRelease(pathRef);

    layer.strokeColor= [borderColorCGColor];

    layer.fillColor= backgroudColor.CGColor;

    UIView*roundView = [[UIViewalloc]initWithFrame:bounds];

    [roundView.layerinsertSublayer:layeratIndex:0];

    roundView.backgroundColor = UIColor.clearColor;

相关文章

  • 需求梳理会

    时间:2020-09-25 地点:1215会议室 参会人:Scrum团队&产品负责&业务方 时长:1.5~2.5h...

  • 函数之参数详解

    函数之参数详解 2020-09-25 Reads 4 位置入参 函数调用时,实参默认按位置顺序传递,需要个数和形参...

  • 2020-09-25

    2020-09-25 【晚上好#商玉玲#20200925日精进简书第4天】印象笔记63天,总第67天 表现分:9分...

  • 【写作100天】3/100 在日常生活中修行

    2020-09-25【写作100天】3/100 在日常生活中修行 从事金融保险经纪人以来,每天都要学习大量的知识,...

  • 别让意识挡住了脚步

    我怎么如此幸运-重生28-戴红霞(2020-09-25) 我怎么如此幸运-别让意识挡住了脚步 1.我怎么如此幸运我...

  • 2020-09-26

    2020-09-25 姓名 :曹静杰 企业名称 : 辽宁辽阳丛迪服装有限公司 组别 388期 反省1组 志工529...

  • 《华与华工作法》【023】华与华改善提案制度简史(2)从个人改善

    《华与华工作法》【022】华与华改善提案制度简史(2)从个人改善提案到周改善提案2020-09-25 时间到了20...

  • 苗寨随记

    2020-09-25 西江千户苗寨客栈内 雨 贵州之行第四天,坐着大巴弯弯绕绕从荔波县城来到了西江...

  • MySQL物理备份

    2020-09-25 物理备份 直接备份数据库文件,适用于大型数据库环境,不受存储引擎的限制,但不能恢复到不同版本...

  • 2020-09-25 孩子长大了 三宝妈成长日记第57篇

    2020-09-25 星期五 晴转阴 三宝妈成长日记第57篇 三宝妈:1.早起学习财务课程,家庭保障体系,对保险有...

网友评论

      本文标题:2020-09-25

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