The following Swift code snippet demonstrated how to make a UIImage circular. It will also show how to:
- Make UIImage Circular programmatically and
- How to add a border around UIImage,
- Change 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
import UIKit class ViewController: UIViewController { @IBOutlet weak var profile_picture: UIImageView! override func viewDidLoad() { super.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() { super.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.