How to round the corners of a button How to round the corners of a button ios ios

How to round the corners of a button


I tried the following solution with the UITextArea and I expect this will work with UIButton as well.

First of all import this in your .m file -

#import <QuartzCore/QuartzCore.h>

and then in your loadView method add following lines

    yourButton.layer.cornerRadius = 10; // this value vary as per your desire    yourButton.clipsToBounds = YES;


You can achieve by this RunTime Attributes

enter image description here

we can make custom button.just see screenshot attached.

kindly pay attention :

in runtime attributes to change color of border follow this instruction

  1. create category class of CALayer

  2. in h file

    @property(nonatomic, assign) UIColor* borderIBColor;
  3. in m file:

    -(void)setBorderIBColor:(UIColor*)color {    self.borderColor = color.CGColor;}-(UIColor*)borderIBColor {    return [UIColor colorWithCGColor:self.borderColor];}

now onwards to set border color check screenshot

updated answer

thanks


Pushing to the limits corner radius up to get a circle:

    self.btnFoldButton.layer.cornerRadius = self.btnFoldButton.frame.height/2.0;

enter image description here

If button frame is an square it does not matter frame.height or frame.width. Otherwise use the largest of both ones.