IOS開發之為視圖繪制單(多)個圓角實例代碼
前言:
為視圖繪制圓角,圓角可以選左上角、左下角、右下角、右上角、全部圓角
//Core Raduias UIView *actionView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:actionView.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = actionView.bounds; maskLayer.path = maskPath.CGPath; actionView.layer.mask = maskLayer;
UIRectCorner枚舉值如下:
typedef NS_OPTIONS(NSUInteger, UIRectCorner) { UIRectCornerTopLeft = 1 << 0, UIRectCornerTopRight = 1 << 1, UIRectCornerBottomLeft = 1 << 2, UIRectCornerBottomRight = 1 << 3, UIRectCornerAllCorners = ~0UL };
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!