UIButton image with rounded corner

2010-07-13

At some point while developing for the iPhone or iPad you'll undoubtfully need to create a button with some odd image and notice it will not apply rounded corners to it. It just won't clip y default. Luckily there is a relatively easy fix for that in version 3.0 and up.

Code: (Objective-C)
CALayer * layer = [myButton layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:10.0];

Do not forget to #import <QuartzCore/QuartzCore.h>

Hope it helps!