我正在以编程方式创建一个 UILabel
。但是下面的代码没有给我圆角。我想我错过了一些非常基本的东西。
var textLabel:UILabel? = UILabel()
textLabel?.text = text
textLabel?.frame = CGRect(x:point.x, y:point.y, width:(textLabel?.intrinsicContentSize.width)!, height:15)
textLabel?.backgroundColor = UIColor.white
textLabel?.font = UIFont(name:"OpenSans", size:8)
textLabel?.sizeToFit()
textLabel?.layer.cornerRadius = 20.0
谁能给我指出正确的方向?
最佳答案
我认为您应该为 textLabel 设置 maskToBounds。试试这个:
textLabel?.layer.masksToBounds = true
关于ios - UILabel swift 的圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46090400/