给按钮加圆角边框(可选某个圆角)

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

view2.backgroundColor = [UIColor redColor];

[self.view addSubview:view2];

 

 

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];

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

maskLayer.frame = view2.bounds;

maskLayer.path = maskPath.CGPath;

view2.layer.mask = maskLayer;

 

byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight

 

 

另一个方法:

  CALayer *lay2  = button.layer;//获取ImageView的层

    lay2.borderColor = borderColor.CGColor;

    lay2.borderWidth = flotBorder;

    [lay2 setMasksToBounds:YES];

    [lay2 setCornerRadius:flotCornerRadius];//值越大,角度越圆

 

posted @ 2014-05-14 10:39  夜深人未静  阅读(319)  评论(0)    收藏  举报