Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.58 KB | None | 0 0
  1. enum TextAttribute {
  2.   case foregroundColor(NSColor)
  3.   case link(URL)
  4.   case kerning(Int)
  5.   case underline(NSUnderlineStyle)
  6.  
  7.   var name: String {
  8.     switch self {
  9.       case .foregroundColor:
  10.         return "NSForegroundColorAttributeName"
  11.  
  12.       case .link:
  13.         return "NSLinkAttributeName"
  14.  
  15.       case .kerning:
  16.         return "NSKernAttributeName"
  17.  
  18.       case .underline:
  19.         return "NSUnderlineStyleAttributeName"
  20.  
  21.     }
  22.   }
  23. }
  24.  
  25. let string = NSAttributedString(string: "My underlined link", attributes: [
  26.   .underline(.single),
  27.   .link(myWebsiteURL)
  28. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement