How to add background color and rounded corners for Strings in iOS?
问题 How to add background color and rounded corners for Strings in iOS? like this picture below: Can't do it with NSAttributedstring . So, should I use CoreText ? I found this answer but still don't know how to do it. 回答1: String is just a data in text format, it's not visual. You need labels, those are labels there. And then set your string to that label. let label = UILabel() label.backgroundColor = .green label.text = "Label" // You set your string to your label label.layer.cornerRadius = 5