Seems to be too busy for a long time, today has been more leisurely, just met a problem: Draw round corner. Not four fillets together, but one or a few rounded corners, then the Layer.cornerradius is not very useful.
For this scenario, several solutions are available on StackOverflow. One of the simplest and most elegant schemes is the use of Uibezierpath. A sample code is given below.
UIView*View2=[[UIViewAlloc]initWithFrame:CGRectMake(120,10,80,80)];View2.BackgroundColor=[Uicolor Redcolor]; [self. View addsubview:view2];
Uibezierpath*Maskpath=[UibezierpathBezierpathwithroundedrect:View2.BoundsByroundingcorners:Uirectcornerbottomleft|UirectcornerbottomrightCornerradii:Cgsizemake(10,10)];Cashapelayer*Masklayer=[[CashapelayerAlloc]Init];Masklayer.Frame=View2.Bounds;Masklayer.Path=Maskpath.cgpath;view2.layer.mask = masklayer
which
Byroundingcorners:uirectcornerbottomleft | Uirectcornerbottomright
Specifies the corners that need to be rounded corners. The parameter is of type Uirectcorner, and the optional values are:
* uirectcornertopleft* uirectcornertopright* uirectcornerbottomleft* uirectcornerbottomright* Uirectcornerallcorners
From the name it is easy to see the meaning of the representative, using the "|" To mix it up just fine.
Thanks to the original author's concise summary! I'll copy it.
Some corners of the specified UIView for iOS development are rounded corners