cloudcal cloudcal - 1 year ago 176
iOS Question

clipsToBounds causes UIImage to not display in iOS10 & XCode 8

I switched my project over to new beta versions of iOS 10 and XCode 8. In all three areas of my app where I use:

imageView.layer.cornerRadius = imageView.frame.size.width/2
imageView.clipsToBounds = true

The associated images are not displaying at all. I have attempted cleaning the project as well as the build folder, restarting the device, trying on various simulators, re-adding the imageView, programmatically setting the associated
instead of choosing one from the assets.

Removing the
line shows the rectangular image regardless of whether
. How can I make a circular image in XCode8 / iOS10 ?

Edit: The project is Swift 2.x and not yet updated to Swift 3.0 syntax.

Answer Source

I had the same problem and calling layoutIfNeeded before all the rounded corner / clipsToBounds stuff fixed the issue. iOS 10 GM with xcode 8 GM causes views to disappear due to roundedCorners

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download