아이폰

Swift Outline UILabel

SourceTree 2021. 11. 20. 08:44
반응형

라벨에 외곽선을 그리는 방법입니다.

let attrString = NSAttributedString(
    string: "외곽선 라벨",
    attributes: [
        NSAttributedString.Key.strokeColor: UIColor.black, 
        NSAttributedString.Key.foregroundColor: UIColor.white, 
        NSAttributedString.Key.strokeWidth: -2.0, 
        NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17.0)
    ]
)
label.attributedText = attrString

 

반응형