iOS view的指定角设置圆弧

来源:互联网 发布:工信部网站域名查询 编辑:程序博客网 时间:2024/05/01 06:53

   UIView *view2 = [[UIViewalloc]initWithFrame:CGRectMake(120,10,80, 80)];

    view2.backgroundColor = [UIColorredColor];

    [self.viewaddSubview:view2];

    

    UIBezierPath *maskPath = [UIBezierPathbezierPathWithRoundedRect:view2.boundsbyRoundingCorners:UIRectCornerBottomLeft |UIRectCornerBottomRight cornerRadii:CGSizeMake(10,10)];

   CAShapeLayer *maskLayer = [[CAShapeLayeralloc]init];

    maskLayer.frame = view2.bounds;

    maskLayer.path = maskPath.CGPath;

    view2.layer.mask = maskLayer;

//    其中,byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight

//    指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:

     UIRectCornerTopLeft

     UIRectCornerTopRight

     UIRectCornerBottomLeft

     UIRectCornerBottomRight

     UIRectCornerAllCorners

0 0
原创粉丝点击