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

2018-06-01  本文已影响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

*/

上一篇 下一篇

猜你喜欢

热点阅读