How to make UItabbar image rounded in swift programmatically

Viewed 2419

I want to create something like image as below could you help me any code how to make it rounded thanks for your help!

enter image description here

3 Answers
    let profileImg : UIImageView = {

        let iv = UIImageView()
        iv.translatesAutoresizingMaskIntoConstraints = false
        iv.contentMode = .scaleAspectFill
        iv.image = #imageLiteral(resourceName: "user")
        iv.clipsToBounds = true
        iv.layer.cornerRadius = 25
        return iv
    }()
// add constraint
     override func viewDidLoad() {
        super.viewDidLoad()
        profileImg.leftAnchor.constraint(equalTo: view.leftAnchor, constant : 8).isActive = true
        profileImg.topAnchor.constraint(equalTo: view.topAnchor , constant : 8).isActive = true
        profileImg.widthAnchor.constraint(equalToConstant: 50).isActive = true
        profileImg.heightAnchor.constraint(equalToConstant: 50).isActive = true
   }
Related