How to make UILabel in Swift a circle

前端 未结 7 1157
孤街浪徒
孤街浪徒 2021-01-04 20:03

I am trying to make a UILabel in Swift a perfect circle. I am currently using the following:

pResult.layer.masksToBounds = true
pResult.layer.cornerRadius =          


        
7条回答
  •  醉梦人生
    2021-01-04 20:20

    If you you want to make perfect circle then first make sure your label width and height are same.

    pResult.layer.cornerRadius = CGRectGetWidth(pResult.frame)/2
    pResult.layer.masksToBounds = true
    

    Reference

提交回复
热议问题