CodePudding user response:
Many times we need a rounded button, and a UIButton controls the borders of the default is square, or do not meet our requirements, then we need to use the code to modify it,[testBtn layer setMasksToBounds: YES];
[testBtn layer setCornerRadius: 8.0];//set the moment radius
[testBtn layer setBorderWidth: 1.0];//border width
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB ();
CGColorRef colorref=CGColorCreate (colorSpace, (CGFloat []) {1, 0, 0, 1});
[testBtn layer setBorderColor: a colorref];//border color
From the jump newest baby