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/
You can simple create extension:
and use it as below:
Don't know if this helps anyone but I was struggling with this problem for awhile, none of the answers online helped me. For me the problem was I had different heights and widths set on the image in storyboard. I tried every solution on stack and it turns out it was something as simple as that. Once I set them both to 200 my circle profile image was perfect. This was code then in my VC.
If you mean you want to make a UIImageView circular in Swift you can just use this code:
That is all you need....
Download and use Toucan from GitHub. It's offered in Swift. Mind numbingly easy. It also offers a bunch of other image effects.
For Swift3/Swift4 Developers: