UILabel Background Color Leaks to Border

前端 未结 6 1949
予麋鹿
予麋鹿 2021-02-19 03:48

I\'m creating a UILabel to which I set the background color and corner radius with the following code:

self.scoreLabel.backgroundColor = [UIColor DISRed];// cust         


        
6条回答
  •  [愿得一人]
    2021-02-19 04:01

    I ran into the same problem with the UIButton's background color leaking around the edge of its border.

    Instead of setting the UIButton background color on the UIButton, set it on the UIButton's layer.

    Replace:

    self.scoreLabel.backgroundColor = [UIColor DISRed];// custom red`
    

    With this:

    self.scoreLabel.layer.backgroundColor = [[UIColor DISRed] CGColor];// custom red`
    

提交回复
热议问题