Though there is solution of this question is present in internet, but I am unable to do so, I want to round a image.
this code I am using:
extension UIImageView {
func makeRounded() {
let radius = self.frame.width/2.0
self.layer.cornerRadius = radius
self.layer.masksToBounds = true
}
}
then i call this function in viewdidload() like imgvw.makeRounded(). but it is not coming. please help
the previous link is not helping me
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var image: UIImageView!
func makeRounded() {
image.layer.borderWidth = 1
image.layer.masksToBounds = false
image.layer.borderColor = UIColor.blackColor().CGColor
image.layer.cornerRadius = image.frame.height/2 //This will change with corners of image and height/2 will make this circle shape
image.clipsToBounds = true
}
Happy Coding