clipsToBounds导致UIImage无法在iOS10和XCode 8中显示

clo*_*cal 28 uiimageview uiimage ios ios10 xcode8

我将我的项目转换为iOS 10和XCode 8的新测试版.在我使用的应用程序的所有三个区域中:

imageView.layer.cornerRadius = imageView.frame.size.width/2
imageView.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)

相关图像根本不显示.我尝试清理项目以及构建文件夹,重新启动设备,尝试各种模拟器,重新添加imageView,以编程方式设置关联,UIImage而不是从资产中选择一个.

卸下clipsToBounds线示出了矩形图像无论masksToBoundstruefalse.如何在XCode8/iOS10中制作圆形图像?

编辑:该项目是Swift 2.x,尚未更新为Swift 3.0语法.

Pra*_*y C 44

我遇到了同样的问题并layoutIfNeeded在所有圆角/ clipsToBounds东西修复问题之前调用.iOS 10 GM与xcode 8 GM导致视图因roundedCorners和clipsToBounds而消失


小智 6

这个问题也发生在我身上.

我把这些代码imageView.layer.cornerRadius = imageView.frame.size.width/2- (void)awakeFromNib- (void)drawRect:(CGRect)rect这个问题就走了.

我的imageView的大小是autolayout.我认为在iOS 10上从nib唤醒时不会决定高度和宽度.