Make UIImage Corners Rounded

The following Swift code example demonstrates how to make UIImage corners rounded.

Additionally, the code snippet below also demonstrates how to:

  • Add a border around UIImage,
  • Change the UIImage border color.

If you are interested in video lessons on how to write Unit tests and UI tests to test your Swift mobile app, check out this page: Unit Testing Swift Mobile App

Making UIImage Corners Rounded

import UIKit
class ViewController: UIViewController {
    @IBOutlet weak var profile_picture: UIImageView!
    override func viewDidLoad() {
        // Make image borders rounded
        profile_picture.layer.cornerRadius = 10
        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.

For more Swift code examples and tutorials, please check the Swift Code Examples page on this website.

Leave a Reply

Your email address will not be published.