UIView with Rounded Corners

Sooner rather than later, you’ll probably end up with a simple yet tricky requirement: an UIView with rounded corners.

iOS SDK has no ‘radius’ property. Ohhh wait!. Yeah, it actually has!. But the catch to it is that you need to import Quartz framework, first:

[cc lang=”objc”]
#import
[/cc]

Also, you need to link the ‘QuartzCore.framework’. Otherwise the import won’t work.

So… how do you actually display an UIView with rounded corners?. Easy!

[cc lang=”objc”]
[_someView.layer setCornerRadius:6];
[/cc]

See?. Just a line of code. Kung fu isn’t about a lot of spaghetti code. It’s about knowing what to do!