ios swift 3 xcode8 beta圆形imageView

使用我的项目,我使用以下代码,以使我的图像为圆形:
profileImage.layer.cornerRadius = profileImage.frame.size.width / 2
profileImage.clipsToBounds = true

我也使用禁忌使我的图像使其宽=高和其他限制.

将我的项目升级到xcode 8 beta和swift 3.我设置为舍入的所有图像视图都消失了,当我删除代码进行四舍五入或者我删除所有的约束,他们再次出现.
但我仍然需要他们圆润.任何人都可以帮我解决问题.
谢谢

解决方法

我有同样的问题,解决方案只是在您的层修改之前移动一行代码.
尝试应用布局更改:
self.view.layoutIfNeeded()

在你的代码之前:

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

要么

将与框架/图层相关的代码放在viewDidLayoutSubviews()方法中:

override func viewDidLayoutSubviews() {

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

}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...