Вам нужно использовать NSAttributedString
, установить strokeColor
и strokeWidth
для установки контура и foregroundColor
для установки цвета текста. Попробуйте это:
let attrString = NSAttributedString(string: "Write Something with Outline", attributes: [NSAttributedStringKey.strokeColor: UIColor.black, NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.strokeWidth: -2.0, NSAttributedStringKey.font: UIFont.systemFont(ofSize: 17.0)])
yourLabel.attributedText = attrString
Это будет выглядеть ниже: