Make UIImage Circular Programmatically

This code snipped demonstrates how to :

  • Make UIImage Circular programmatically and
  • How add a boarder around UIImage
  • Change UIImage border color

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var profile_picture: UIImageView!
    override func viewDidLoad() {

        // Make image circular
        profile_picture.layer.cornerRadius = profile_picture.frame.size.width / 2
        profile_picture.clipsToBounds = true
        profile_picture.layer.borderWidth = 3
        profile_picture.layer.borderColor = UIColor.white.cgColor

    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated.

Watch this video tutorial to see how to make UIImage circular in Xcode using Main storyboard.

Circular Image or Image with Rounded Corners. Example in Swift


Learn iOS Development with these Video Courses

How to Make a Freaking iPhone App - iOS 10 and Swift 3
icon icon

iOS 10 & Swift 3: From Beginner to Paid Professional

The Complete iOS 10 Developer Course - Build 21 Apps

Swift 3 - Learn to Code with Apple's New Language
icon icon

Learn How to Build Mobile Apps for iOS with Swift, PHP and MySQL
icon icon

Follow me on one of your favourite social networks to learn about new video tutorials and code examples:

Twitter: @SwiftVideoBlog
Google Plus:
Facebook: Swift Developer Blog on Facebook