iOS 17.0 UIGraphicsBeginImageContext閃退問(wèn)題

之前文章有講過(guò)Images.xcassets圖片拉伸,可以對(duì)圖片進(jìn)行局部拉伸。
從iOS 7到現(xiàn)在,也一直這么使用的,在iOS 17上運(yùn)行時(shí)出現(xiàn)了問(wèn)題。

圖片是22×2像素的矩形圖片,我對(duì)圖片進(jìn)行了拉伸設(shè)置

Slicing

在iOS 17.1和iOS 17.2上運(yùn)行時(shí),圖片不顯示
在iOS 17.0上運(yùn)行時(shí)(iOS 17.0.2、iOS 17.0.3),閃退,報(bào)錯(cuò)如下:

*** Assertion failure in void _UIGraphicsBeginImageContextWithOptions (CGSize, BOOL, CGFloat,
BOOL) (), UIGraphics.m:410
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={66, nan}, scale=2.000000, bitmapInfo=0×2002. Use UIGraphicsImageRenderer to avoid this assert.'
*** First throw call stack:
(0x1b309e5e0 0x1ab3d3c00 0x1b2608404 0x1b52b88b0 0x1b52b687c 0x1b51dedd4 0x151dd148 0x1b5225aec
0x1b5225564 0x1b2fe6d94 0x1b2fe6b30 0x1b51dd7cc 0x1b520133c 0x1b51f8464 0x1b51f8a6c 0x1b51f7184
0x1b460f888 0x1b51fa250 0x1b5206218 0x1b544e1f0 0x1b544da70 0x1b544bfbc 0x1b544baa4 0x1b51f7184
0x1b460f888 0x1b460f410 0x1b461594c 0x1b460ec3c 0x1b460e8e4 0x1b526f228 0x1b526ed40 0x1b526e430
0x1b526e4ec 0x1b2fe8acc 0x1b2fe7d48 0x1b2fe64fc 0x1b2fe5238 0x1b2fe4e18 0x1f5aa95ec 0x1b53f32fc
0x1b53f2938 0x1009fd28c 0x1d57cfd44)
libc++abi: terminating due to uncaught exception of type NSException

其他圖片拉伸則沒(méi)有這個(gè)問(wèn)題

根據(jù)查閱的資料,iOS 17上使用UIGraphicsBeginImageContext(),size為0時(shí),就會(huì)報(bào)相同的錯(cuò)誤。
我估計(jì)我這個(gè)問(wèn)題應(yīng)該是topbottom設(shè)置為0的原因,內(nèi)部也是通過(guò)UIGraphicsBeginImageContext()實(shí)現(xiàn)的。

具體可參考:
iOS-bug,Xcode,iOS17,“UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}
ReactNative中升級(jí)IOS 17版本Crash解決

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容