In iOS development, we often encounter the problem of view setting fillet, if we need to uiview 4 corners all rounded, it is quite simple, just set the Cornerradius property of its layer (the project needs to use the Quartzcore framework). This method is not good when you want to specify a few corners (less than 4) to be rounded and the other constant.
For the latter case, the following is a relatively simple and elegant scheme, that is, the use of Uibezierpath.
The sample code is as follows:
UIView *testview = [[UIView Alloc] initWithFrame:CGRectMake (100,10,80,];testview).backgroundcolor = [uicolor redcolor];[ self.view Addsubview:testview]; uibezierpath *maskpath = [uibezierpath bezierpathwithroundedrect: Testview.bounds byroundingcorners:uirectcornerbottomleft | uirectcornerbottomright cornerradii:cgsizemake (10, 10)]; cashapelayer *masklayer = [[cashapelayer Alloc] Init];masklayer.frame = Testview.bounds;masklayer.path = maskpath< span class= "variable". Cgpath;testview.layer.mask = Masklayer;
Among them, 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.
Some corners of the specified UIView for iOS development (less than 4) are rounded corners