2016-01-07 09:52:54.237 BabyWatcher[2700:960906] *** Assertion failure in -[UICGColor encodeWithCoder:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UIColor.m:1455
2016-01-07 09:52:54.244 BabyWatcher[2700:960906] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
*** First throw call stack:
(0x180a95900 0x180103f80 0x180a957d0 0x18140899c 0x185bc4110 0x1813cf3f0 0x1813d6258 0x185eaa734 0x185ea5918 0x1809816d8 0x1809815b0 0x185ea561c 0x186094060 0x185f62534 0x185f62318 0x185e24444 0x1011f5bf0 0x1011f5bb0 0x1011fb658 0x180a4cbb0 0x180a4aa18 0x180979680 0x181e88088 0x1857f0d90 0x1000f6670 0x18051a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
原生输入法不会出现问题,但是使用第三方输入法就立刻崩溃(百度、搜狗等)。
解决:
方案一:
颜色设为RGB,不使用colorWithPatternImage方法。
方案二:
删除所有的colorWithPatterImage方法,[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"back.png"]]];
统一的导航条颜色设置放在BaseController中解决。
更多调研
不满足于上述解决方案,我进行了下面的尝试…
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"btnPink"]];
UIColor * color2 = [UIColor colorWithRed:0.898 green:0.325 blue:0.455 alpha:1.000];
发现colorWithPatternImage:和colorWithRed:green:blue 这两个方法返回值(isa)不一样,color isa->CGColor,color2 isa->UIDeviceRGBColor。
崩溃信息说了这种场景只支持rgba或者white color spaces,于是我想是否可以将cgcolor转化为rgbcolor,尝试CGColorGetComponents(color.CGColor)方法转换失败
问:究竟为何此方法会与第三方输入法冲突?我尝试的思路是否准确?