UILabel Background Color Leaks to Border

前端 未结 6 1920
予麋鹿
予麋鹿 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:22

    I was also facing the same problem. It was a silly mistake. I always forget to tick clipToBounds in case of cornerRadius.

    So, just ticking the Clip to Bounds for UILabel in Storyboard fixed my problem.

    And yes, we need to keep the below code too:

    label.layer.masksToBounds = true
    

提交回复
热议问题