How to Create Round or Round Corner Imageview image in swift 4 xcode 9

Swift n Objective-C

Hi, Guys. It is like a Tutorial kind of Post or Article. I hope it is useful or helpful for all iOS Application developers. Earlier, there is no proper or standard logic for Round corner or Round Imageview in iOS. As an experienced developer, i found a simple logic or method for that, you just go through below given instructions.

To Apply Round Corner or Create Round Imageview image, your Imageview Height & Width should be Same. (width:100, Height:100)

Declaring or creation Object to UIButton Class Component

  –>  @IBOutlet weak var imgview: UIImageView!

Create Below given Method as Shown…


   func applyRoundRect(_ object:AnyObject) {

        object.layer.cornerRadius = object.frame.size.width / 2

        object.layer.masksToBounds = true        

    }

Applying Round Corner Follow Below…


        self.applyRoundRect(imgview)

 

Sample Source Code: RoundImage.zip

Leave a Reply