When I used Chinese UITableview cell will be color blended

后端 未结 2 1263
陌清茗
陌清茗 2021-01-16 00:10

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.img

相关标签:
2条回答
  • 2021-01-16 01:03

    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.

    0 讨论(0)
  • 2021-01-16 01:13

    Solution for Chinese characters for red:

    label.layer.maskToBounds = true

    0 讨论(0)
提交回复
热议问题