UIButton *testbutton = [UIButton buttonwithtype:uibuttontypesystem];
[Testbutton setframe: cgrectmake (self. View. Frame. Size. Width/2self. View. Frame. Size. Height/2100100
[Testbutton settitle:@ " get screen size " forstate:uicontrolstatenormal];
[Testbutton. layer setmaskstobounds:YES]; setting the corner radius of a button is not obscured
[Testbutton. layer setcornerradius:ten];
[Testbutton. layer setborderwidth:2]; set the width of the boundary
// Set the border color of the button
cgcolorspaceref colorspaceref = Cgcolorspacecreatedevicergb();
cgcolorref color = cgcolorcreate(Colorspaceref, (cgfloat[]) {1,0,0 ,1});
[Testbutton. layer setbordercolor: color];
[Testbutton addTarget:self action:@selector(Touch) forcontrolevents: UIControlEventTouchUpInside];
[self. View addsubview: Testbutton];
Implementation results:
Uikit--uibutton setting borders in iOS