Pages

Thursday, December 15, 2011

[Code Snippet] Rounded corners for UIView

We are very sorry about the lack of updates for the block, but now we are overloaded of projects and have no much time to write new posts :(

Here is a little and useful code snippet to round the corners of any UIView (UIWebView, UIImageView, etc...)

You have just to link your binaries with QuartzCore library and import it in the .h file.

#import <QuartzCore/QuartzCore.h>

And in .m file, you have to use this code snippet to round the corners. In the examble I've did it with a UIImageView

[imgView.layer setBorderColor:[UIColor blackColor].CGColor];
[imgView.layer setBorderWidth:1.0f];
                    
[imgView.layer setCornerRadius:10];
[imgView setClipsToBounds:YES];

With this four lines of code, you'll give your app a better look and feel.

Enjoy it!!

P.S. Don't forget to visit our web to see a complete catalogue of our apps.

No comments:

Post a Comment