Show Menu

Need an iOS Developer?

Submit your 30 day Job Listing for FREE

Rounded avatars seem to be very fashionable these days. Even Apple adopted the rounded images for contacts. If you’re wondering how to achieve this in your app here is the answer.

All we need to do is adjust the CALayer for the image view representing the avatar:

self.avatarImageView.layer.cornerRadius = 150.0f;
self.avatarImageView.layer.borderWidth = 2.0f;
self.avatarImageView.layer.borderColor = [UIColor blackColor].CGColor;
self.avatarImageView.clipsToBounds = YES;

The value for the corner radius is exactly half the width of the image. We’ll assume that we have a square image of size 300×300 otherwise we won’t get a perfect circle. We’ll add a nice black border and we’ll set the property clipsToBounds to YES. The clipsToBounds property needs to be YES for this to work. And there you have it, a big round image.

having issues?

We have a Questions and Answer section where you can ask your iOS Development questions to thousands of iOS Developers.

Ask Question

FREE Download!

Get your FREE Swift 2 Cheat Sheet and quick reference guide PDF download when you sign up to SwiftMonthly

Sharing is caring

If you enjoyed this tutorial, please help us and others by sharing using one of the social media buttons below.

Written by:

Vasilica Costescu is just a girl that loves her iPhone and iOS programming, she graduated from: West University of Timisoara with a degree in Computer Science in 2006. Her blog has awesome articles. Check it out.