ios - 有时在 iOS Swift 上渲染粉色容器的图像资源
问题描述
我在 iOS 手机设备 (Swift) 上看到我的图像资产出现奇怪错误。
所以.. 有时,图像资产被粉红色的容器覆盖。上周之前我没有任何这些错误,不知何故我现在看到了。
图像文件是 png 文件,我将其设置为“渲染为默认”或“渲染为原始图像”。XCode 模拟器上不会发生该错误。
但是,当我将它上传到任何 iOS 设备时,它就会发生。
class EditButton: UIButton {
init() {
super.init(frame: .zero)
setImage(UIImage(named: "editPencil"), for: .normal)
contentMode = .center
imageView?.contentMode = .scaleAspectFit
imageView?.isUserInteractionEnabled = true
clipsToBounds = true
translatesAutoresizingMaskIntoConstraints = false
widthAnchor.constraint(equalToConstant: 10).isActive = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
有趣的是我在其他 png 文件中没有这些错误..
解决方案
推荐阅读
- r - Saving user input (Shiny app) to a global variable in R
- php - 使用 MAMP 5.1 (php7.2) 在 Mac 上安装 mcrypt
- javascript - 在 Vue.js 中将值异步推送到数组
- android - 永远不会调用 onReceive() 方法后的应用程序升级
- laravel - The local project works correctly, but it does not find the url's server
- c# - DotNetCore 中的 System.Web.Security MemberShipUser 是否有任何替代方案
- android - 如何编辑图标旁边的通知文本?
- php - 使脚本响应来自 PHP 的回声
- mysql - SQL:查询两个单独的表并返回计数值,然后按两个返回分组
- swift - Swift 4 切换到新的观察 API