【发布时间】:2020-01-26 16:47:12
【问题描述】:
我正在尝试用UIColor 设置searchbar 背景图像。我的代码在 ios 12.x 中运行良好,但在 ios 13 中崩溃。我的代码如下。
[[UISearchBar appearance] setScopeBarBackgroundImage:[UIImage imageWithCGImage:(__bridge CGImageRef)([UIColor clearColor])]];
崩溃日志显示由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“通过的 imageRef 不是 CGImageRef”
谁能提出解决崩溃的替代方法?
【问题讨论】:
-
令人惊讶的是,在 iOS 13 之前没有给您带来麻烦...这:
(__bridge CGImageRef)([UIColor clearColor])确实 不 返回CGImage/CGImageRef。
标签: ios objective-c uiimage uisearchbar