美文网首页
控件设置一个或者多个圆角

控件设置一个或者多个圆角

作者: 梁苏珍 | 来源:发表于2018-06-01 09:10 被阅读0次

 self.view.backgroundColor = [UIColor whiteColor];

    UIView* cornerView = [[UIViewalloc]init];

    cornerView.frame=CGRectMake(100,100,100,100);

    cornerView.backgroundColor = [UIColor yellowColor];

    [self.viewaddSubview:cornerView];

    //下面是shezhi

    UIBezierPath  * maskPath= [UIBezierPath  bezierPathWithRoundedRect:cornerView.bounds

                                                    byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight

                                                          cornerRadii:CGSizeMake(20,20)];

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

    maskLayer.frame= cornerView.bounds;

    maskLayer.path= maskPath.CGPath;

    cornerView.layer.mask= maskLayer;

    //显而易见 处理圆角的参数 还可以自由组合     用 | 隔开处理

/*

     UIRectCornerTopLeft

     UIRectCornerTopRight

     UIRectCornerBottomLeft

     UIRectCornerBottomRight

     UIRectCornerAllCorners

*/

相关文章

网友评论

      本文标题:控件设置一个或者多个圆角

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