iOS: round framed UIbutton

You can manipulate the CALayer of your button to do this pretty easily.
// assuming you have a UIButton or more generally a UIView called buyButton

.layer.cornerRadius = 2;
.layer.borderWidth = 1;
.layer.borderColor = [UIColor blueColor].CGColor;
// (note - may prefer to use the tintColor of the control)
you can tweak each of those to get the color and border effect you want.
You will also have to add an import in any file you want to use CALayers

Import QuartzCore.h

If you are a big fan of using storyboards for your UI design with iOS, you can set the corner radius (although unfortunately not the color) in the identity inspector->user defined runtime attributes in storyboard as shown here:

enter image description here

Leave a Comment