UIView setting rounded corners
1, relatively simple situation, uiview Four Corners are rounded corner:
UIView *aview = [[UIView alloc] init]; Aview.frame = CGRectMake (0, 0, +); Aview.backgroundcolor = [Uicolor redcolor]; Set rounded border AView.layer.cornerRadius = 8; AView.layer.masksToBounds = YES; Set border and border color aView.layer.borderWidth = 8; AView.layer.borderColor =[[Uicolor Graycolor] cgcolor]; [Self.view Addsubview:aview];
2. Set one or a few of the four corners as rounded corners
UIView *aview = [[UIView alloc] init]; Aview.frame = CGRectMake (0, 0, +); Aview.backgroundcolor = [Uicolor redcolor]; [Self.view Addsubview:aview]; Set the desired fillet position and size uibezierpath *maskpath = [Uibezierpath bezierPathWithRoundedRect:aView.bounds byroundingcorners : Uirectcornerbottomleft | Uirectcornerbottomright Cornerradii:cgsizemake (Ten)]; Cashapelayer *masklayer = [[Cashapelayer alloc] init]; Masklayer.frame = aview.bounds; Masklayer.path = Maskpath.cgpath; AView.layer.mask = Masklayer;
Among them, Uirectcornerbottomleft,uirectcornerbottomright is the angle that can be selected.
typedef ns_options (Nsuinteger, Uirectcorner) { Uirectcornertopleft = 1 << 0, Uirectcornertopright = 1 << 1, uirectcornerbottomleft = 1 << 2, Uirectcornerbottomright = 1 << 3, uirectcornerallcorners = ~0ul};
The above enumeration is a corner that you can choose from: Top left, top right, bottom left, bottom right, and so on.
IOS UIView Setting rounded corners