Swift 알파값 적용하여 텍스트 출력
2021. 1. 5. 21:17ㆍ아이폰 개발
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .left
let attributes: [NSAttributedString.Key : Any] = [
.paragraphStyle: paragraphStyle,
.font: UIFont.systemFont(ofSize: 8.0),
.foregroundColor: UIColor.black.withAlphaComponent(0.4)
]
let attributedString = NSAttributedString(string: place.getName(), attributes: attributes)
let stringRect = CGRect(x: x+7, y: y-6, width: 100, height: 20)
attributedString.draw(in: stringRect)
www.hackingwithswift.com/articles/113/nsattributedstring-by-example
stackoverflow.com/questions/47982390/uitextfield-attributedplaceholder-color-and-opacity-in-swift-4
stackoverflow.com/questions/42498721/drawing-text-over-core-graphics-in-swift-3