问题描述
我将项目切换到了iOS 10和XCode 8的新beta版本.在我使用的应用的所有三个区域中:
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
关联的图像完全不显示.我试图清理项目以及构建文件夹,重新启动设备,尝试使用各种模拟器,重新添加imageView,以编程方式设置关联的UIImage
,而不是从资产中选择一个.
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 UIImage
instead of choosing one from the assets.
删除clipsToBounds
行将显示矩形图像,而不管masksToBounds
是true
还是false
.如何在XCode8/iOS10中制作圆形图像?
Removing the clipsToBounds
line shows the rectangular image regardless of whether masksToBounds
is true
or false
. How can I make a circular image in XCode8 / iOS10 ?
该项目为Swift 2.x,尚未更新为Swift 3.0语法.
The project is Swift 2.x and not yet updated to Swift 3.0 syntax.
推荐答案
我遇到了同样的问题,并在所有圆角/clipsToBounds
问题解决之前,调用了layoutIfNeeded
. 带有xcode 8 GM的iOS 10 GM由于roundedCorners& clipsToBounds
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 & clipsToBounds
这篇关于clipsToBounds导致UIImage无法在iOS10及更高版本中显示. XCode 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!