Iphone: button corner radius not set

In my nib file, I selected one custom button and I want to set its corner radius. I contacted the QuartzCore framework and then I will write the following code to set its angular radius

[[btnPressureLink layer] setCornerRadius:15.0]; 

and when I add the background color for the button, the corner radius is set, but when I put the image on the button, the corner radius is not set. What needs to be done to set the radius of the angle when the image is used on the button?

+6
source share
4 answers

Try

  btnPressureLink.layer.cornerRadius = 15.0; [btnPressureLink.layer setMasksToBounds:YES]; 
+10
source

You can also use this,

 [[btnPressureLink layer]setCornerRadius:4.0f]; [[btnPressureLink layer]setMasksToBounds:YES]; 
0
source

Import the quartz core and try this ...

 button.layer.borderWidth = 2.0; button.layer.cornerRadius = 12; [button.layer setMasksToBounds:YES]; 
0
source

Swift 4

 self.buttonDone.layer.masksToBounds = true //round shape self.buttonDone.layer.cornerRadius = buttonDone.bounds.height/2 //custom shape self.buttonCancel.layer.cornerRadius = 12 
0
source

Source: https://habr.com/ru/post/914296/


All Articles