使用我的项目,我使用以下代码,以使我的图像为圆形:
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 }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。