clipsToBounds 导致 UIImage 在 iOS10 & 中不显示代码 8

clipsToBounds causes UIImage to not display in iOS10 amp; XCode 8(clipsToBounds 导致 UIImage 在 iOS10 amp; 中不显示代码 8)
本文介绍了clipsToBounds 导致 UIImage 在 iOS10 & 中不显示代码 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的项目切换到 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 行会显示矩形图像,无论 masksToBoundstrue 还是 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 导致视图因圆角而消失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 & 中不显示代码 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)