When I used Chinese UITableview cell will be color blended

房东的猫 提交于 2020-01-21 10:04:23

问题


When I enable my simulator debug option "Color blended laysers" Then showing the different result as follow:

Sorry that I can not post images:

http://i.imgur.com/LYiPCfy.jpg?1

http://i.imgur.com/t7hArne.jpg?1


回答1:


It looks like labels with Chinese characters will have an extra sublayer (not subviews).

When I add two UILabels to a view, one with English characters and one with Chinese, there are slightly different hierarchies.

0x7fd3b972c020 is the UILabel with English characters:

(lldb) po [[0x7fd3b972c020 layer] sublayers]
 nil
(lldb) po [0x7fd3b972c020 layer]
<_UILabelLayer:0x7fd3b972c2b0; position = CGPoint (187.5 333.75); bounds = CGRect (0 0; 133 20.5); delegate = <UILabel: 0x7fd3b972c020; frame = (121 323.5; 133 20.5); text = 'This is just a test.'; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fd3b972c2b0>>; contents = <CABackingStore 0x7fd3bb0e1530 (buffer [266 41] BGRX8888)>; opaque = YES; allowsGroupOpacity = YES; rasterizationScale = 2; contentsScale = 2>

0x7fd3b95208f0 is the UILabel with Chinese characters:

(lldb) po [[0x7fd3b95208f0 layer] sublayers]
<CALayerArray 0x7fd3bb0e0c90>(
<_UILabelContentLayer:0x7fd3bb0e0a60; position = CGPoint (68.25 11); bounds = CGRect (0 0; 140.5 29); contents = <CABackingStore 0x7fd3bb0e1180 (buffer [281 58] BGRA8888)>; allowsGroupOpacity = YES; rasterizationScale = 2; contentsScale = 2>
)


(lldb) po [0x7fd3b95208f0 layer]
<_UILabelLayer:0x7fd3b950ba70; position = CGPoint (187.5 361.75); bounds = CGRect (0 0; 136 20.5); delegate = <UILabel: 0x7fd3b95208f0; frame = (119.5 351.5; 136 20.5); text = '这只是一个测试。'; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fd3b950ba70>>; sublayers = (<_UILabelContentLayer: 0x7fd3bb0e0a60>); opaque = YES; allowsGroupOpacity = YES; rasterizationScale = 2; contentsScale = 2>

Each of the views have opaque enabled with white background colors.




回答2:


Solution for Chinese characters for red:

label.layer.maskToBounds = true



来源:https://stackoverflow.com/questions/31759796/when-i-used-chinese-uitableview-cell-will-be-color-blended

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!