guard let font = UIFont(name: "Helvetica-Bold", size: 14) else { return }
let foregroundColor = UIColor(red: 51 / 255.0, green: 51 / 255.0, blue: 51 / 255.0, alpha: 1.0)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 0.2 * font.lineHeight
paragraphStyle.alignment = NSTextAlignment.center
titleLabel.attributedText = NSAttributedString(string: "Hello World", attributes: [ .font: font, .foregroundColor: foregroundColor, .paragraphStyle: paragraphStyle])
2. 두개의 폰트 붙여쓰기(Cat)
let helveticaFont = UIFont(name: "Helvetica-Bold", size: 15) ?? UIFont.systemFont(ofSize: 15)
let zapfinoFont = UIFont(name: "Zapfino", size: 20) ?? UIFont.systemFont(ofSize: 20)
let attString1 = NSMutableAttributedString(string: "Destination", attributes: [NSAttributedStringKey.font: helveticaFont, NSAttributedStringKey.foregroundColor: UIColor.red])
let attString2 = NSMutableAttributedString(string: "Source", attributes: [NSAttributedStringKey.font: zapfinoFont, NSAttributedStringKey.foregroundColor: UIColor.blue])
attString1.append(attString2)
label.attributedText = attString1
![]() |
캡션 추가 |
댓글 없음:
댓글 쓰기