With my project I use the following code in order to make my images in rounded shape:
profileImage.layer.cornerRadius = profileImage.frame.size.width / 2
profileImage.clipsToBounds = true
I also use contrains for my image to make it width = hight
, and other constrains.
After ugrading my project to xcode 8 beta, and swift 3. All the images views that I set to rounded were disappeared, and when I remove the code for making it rounded or I remove all the constrains they appear again.
But I still need them to be rounded. Anyone can help me to fix the issue.
Thanks
I had the same problem, the solution was just to move a line of code before your layer modifications. Try to apply layout changes:
self.view.layoutIfNeeded()
before your code:
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true
OR
place your code related to frames / layers into viewDidLayoutSubviews()
method:
override func viewDidLayoutSubviews() {
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With