Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum TextAttribute {
- case foregroundColor(NSColor)
- case link(URL)
- case kerning(Int)
- case underline(NSUnderlineStyle)
- case custom(key: String, value: Any)
- var name: String {
- switch self {
- case .foregroundColor:
- return "NSForegroundColorAttributeName"
- case .link:
- return "NSLinkAttributeName"
- case .kerning:
- return "NSKernAttributeName"
- case .underline:
- return "NSUnderlineStyleAttributeName"
- case let .custom(key, _):
- return key
- }
- }
- }
- let string = NSAttributedString(string: "My underlined link", attributes: [
- .custom(key: "myCustomAttribute", value: 5),
- .link(myWebsiteURL)
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement