In iOS development, any visible view is inherited from the UIView. In the inheritance system, most of the UIView properties apply to any of their children.
The Layer property of UIView can draw various effects of uiview. Actually the view animation we see is actually a layer in the drawing.
1. Draw rounded Corners
CornerView.layer.cornerRadius =; CornerView.layer.masksToBounds = YES;
Maskstobounds prevents child elements from spilling over the parent view.
If a square is to be set to a circle, the code is:
CornerView.layer.cornerRadius = CORNERVIEW.FRAME.SIZE.HEIGHT/2; CornerView.layer.masksToBounds = YES;
2. Draw the Border
BorderView.layer.borderWidth = 1.0; BorderView.layer.borderColor = [Uicolor blackcolor]. Cgcolor;
Note that Cgcolor is used instead of uicolor.
3. Draw Shadows
Redcolor]. Cgcolor; ShadowView.layer.shadowOffset = Cgsizemake (5.0, 5.0); shadowView.layer.shadowOpacity = YES;
Offset is the shift offset, which is the direction in which the increment of the frame x, y coordinates is being expressed.
The opacity is transparent, and the default is 0, which means transparency. So we're going to set the opacity to 1 or yes, which means it's opaque, or it can be set to 0.5 or a similar value to be translucent.
The effect is as follows:
Uiview,uibutton,uiimageview such as setting rounded corners, setting the shadow, setting the Border method