Pixel Pixel - 17 days ago 5
iOS Question

How to set image in circle in swift

How can i make i circle picture with swift ?

My ViewController :

import UIKit
import Foundation

class FriendsViewController : UIViewController{

@IBOutlet weak var profilPicture: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()
profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100))
}
}


My
profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100))
do nothing ..

Exemple: http://www.appcoda.com/ios-programming-circular-image-calayer/

Jon Jon
Answer
import UIKit

class ViewController: UIViewController {
  @IBOutlet weak var image: UIImageView!

  override func viewDidLoad() {
    super.viewDidLoad()

    image.layer.borderWidth = 1
    image.layer.masksToBounds = false
    image.layer.borderColor = UIColor.blackColor().CGColor
    image.layer.cornerRadius = image.frame.height/2
    image.clipsToBounds = true
}

That is all you need....