(iOS开发)UIButton 半边圆角

//1 、创建好 myButton 的各项

//2、添加以下代码,实现半边圆角(下边的半边圆角)

//3、想改变半边圆角,可以通过改变UIRectCornerBottomLeft | UIRectCornerBottomRight 

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

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

    maskLayer.frame = myButton.bounds;

    maskLayer.path = maskPath.CGPath;

    myButton.layer.mask = maskLayer;


// 全部圆角 
myButton.layer.cornerRadius=2;


你可能感兴趣的:(iOS开发)