Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Cocoa text talk.key

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Css1 properties
Css1 properties
Chargement dans…3
×

Consultez-les par la suite

1 sur 89 Publicité

Cocoa text talk.key

Télécharger pour lire hors ligne

Chad Sellers of Useful Fruit Software presenting at Baltimore Cocoa on the Cocoa Text System. Video available at http://baltimorecocoa.com/post/1167471671/cocoa-text-system-video-slides

Chad Sellers of Useful Fruit Software presenting at Baltimore Cocoa on the Cocoa Text System. Video available at http://baltimorecocoa.com/post/1167471671/cocoa-text-system-video-slides

Publicité
Publicité

Plus De Contenu Connexe

Les utilisateurs ont également aimé (20)

Publicité

Similaire à Cocoa text talk.key (20)

Cocoa text talk.key

  1. 1. Cocoa Text Chad Sellers Useful Fruit Software 9/8/2010
  2. 2. What is Cocoa Text
  3. 3. What is Cocoa Text • High level text framework
  4. 4. What is Cocoa Text • High level text Cocoa Text framework
  5. 5. What is Cocoa Text • High level text Cocoa Text framework • As opposed to Core Text
  6. 6. What is Cocoa Text • High level text Cocoa Text framework • As opposed to Core Text Core Text
  7. 7. What is Cocoa Text • High level text Cocoa Text • Pre-made widgets framework • Lots of UI • As opposed to Core Text Core Text
  8. 8. What is Cocoa Text • High level text Cocoa Text • Pre-made widgets framework • Lots of UI • As opposed to Core Text Core Text • Do it yourself
  9. 9. Text Rendering
  10. 10. Text Rendering • Fonts
  11. 11. Text Rendering • Fonts • Bold/Underline/Italics
  12. 12. Text Rendering • Fonts • Bold/Underline/Italics • Colors
  13. 13. Text Rendering • Fonts • Bold/Underline/Italics • Colors • Kerning
  14. 14. Text Rendering • Fonts • Bold/Underline/Italics • Colors • Kerning • Ligature (fi fi)
  15. 15. Text Rendering • Fonts • Bold/Underline/Italics • Colors • Kerning • Ligature (fi fi) • Baseline
  16. 16. Text Rendering • Fonts • Inline attachments • Bold/Underline/Italics • Colors • Kerning • Ligature (fi fi) • Baseline
  17. 17. Much more
  18. 18. Much more • Layout
  19. 19. Much more • Layout • Editing
  20. 20. Much more • Layout • Editing • cursor
  21. 21. Much more • Layout • Editing • cursor • input handling
  22. 22. Much more • Layout • Editing • cursor • input handling • Spelling/Grammar
  23. 23. Much more • Layout • Editing • cursor • input handling • Spelling/Grammar • Finding
  24. 24. Much more • Layout • Substitutions • Editing • cursor • input handling • Spelling/Grammar • Finding
  25. 25. Much more • Layout • Substitutions • Editing • Transformations • cursor • input handling • Spelling/Grammar • Finding
  26. 26. Much more • Layout • Substitutions • Editing • Transformations • cursor • Speech • input handling • Spelling/Grammar • Finding
  27. 27. Much more • Layout • Substitutions • Editing • Transformations • cursor • Speech • input handling • Dictionary • Spelling/Grammar • Finding
  28. 28. Much more • Layout • Substitutions • Editing • Transformations • cursor • Speech • input handling • Dictionary • Spelling/Grammar • and more • Finding
  29. 29. Sample code
  30. 30. Sample code TextEdit /Developer/Examples/TextEdit
  31. 31. NSString
  32. 32. NSString • Plain text
  33. 33. NSString • Plain text • Immutable
  34. 34. NSString • Plain text • Immutable • NSMutableString isn’t
  35. 35. NSString • Plain text • Immutable • NSMutableString isn’t • Literal - @”literal”
  36. 36. NSString • Plain text • Immutable • NSMutableString isn’t • Literal - @”literal” • Handles encodings
  37. 37. NSString • Plain text • Immutable • NSMutableString isn’t • Literal - @”literal” • Handles encodings • Methods to split/join/etc.
  38. 38. NSString • Plain text • Immutable • NSMutableString isn’t • Literal - @”literal” • Handles encodings • Methods to split/join/etc. • - (NSString *)substringWithRange:(NSRange)aRange
  39. 39. NSString • Plain text • Immutable • NSMutableString isn’t • Literal - @”literal” • Handles encodings • Methods to split/join/etc. • - (NSString *)substringWithRange:(NSRange)aRange • - (NSString *)stringByAppendingPathComponent:(NSString *)aString
  40. 40. NSAttributedString
  41. 41. NSAttributedString • Rich text
  42. 42. NSAttributedString • Rich text • Attributes applied over a range
  43. 43. NSAttributedString • Rich text • Attributes applied over a range • Foundation version not too useful alone
  44. 44. NSAttributedString • Rich text • Attributes applied over a range • Foundation version not too useful alone • AppKit Additions make it useful
  45. 45. NSAttributedString • Rich text • Attributes applied over a range • Foundation version not too useful alone • AppKit Additions make it useful • Adds useful attributes (e.g. NSFontAttributeName)
  46. 46. NSAttributedString • Rich text • Attributes applied over a range • Foundation version not too useful alone • AppKit Additions make it useful • Adds useful attributes (e.g. NSFontAttributeName) • Methods for reading/writing common formats
  47. 47. NSAttributedString • Rich text • Attributes applied over a range • Foundation version not too useful alone • AppKit Additions make it useful • Adds useful attributes (e.g. NSFontAttributeName) • Methods for reading/writing common formats • RTF/RTFD, HTML, Word Doc, Open XML, OpenDoc
  48. 48. Attributes
  49. 49. Attributes Attributes make strings fun!
  50. 50. Attributes Attributes make strings fun! NSForegroundColorAttributeName [NSColor redColor]
  51. 51. Attributes Attributes make strings fun! NSForegroundColorAttributeName NSFontAttributeName [NSColor redColor] [NSFont fontWithName:@”Monaco” size:48]
  52. 52. Attributes Attributes make strings fun! NSForegroundColorAttributeName NSFontAttributeName [NSColor redColor] [NSFont fontWithName:@”Monaco” size:48] NSUnderlineStyleAttributeName [NSNumber numberWithInt:NSUnderlineStyleDouble]
  53. 53. Attributes Attributes make strings fun! NSForegroundColorAttributeName NSFontAttributeName [NSColor redColor] [NSFont fontWithName:@”Monaco” size:48] NSUnderlineStyleAttributeName [NSNumber numberWithInt:NSUnderlineStyleDouble]
  54. 54. NSMutableAttributedString
  55. 55. NSMutableAttributedString • Mutable version of NSAttributedString
  56. 56. NSMutableAttributedString • Mutable version of NSAttributedString • Also has AppKit additions
  57. 57. NSTextStorage
  58. 58. NSTextStorage • Subclass of NSMutableAttributedString
  59. 59. NSTextStorage • Subclass of NSMutableAttributedString • Main text storage class used in Cocoa Text
  60. 60. NSTextStorage • Subclass of NSMutableAttributedString • Main text storage class used in Cocoa Text • Manages NSLayoutManagers
  61. 61. NSTextStorage • Subclass of NSMutableAttributedString • Main text storage class used in Cocoa Text • Manages NSLayoutManagers • which layout text into text containers
  62. 62. NSTextView
  63. 63. NSTextView • View for displaying/editing rich text
  64. 64. NSTextView • View for displaying/editing rich text • Contains NSTextContainer
  65. 65. NSTextView • View for displaying/editing rich text • Contains NSTextContainer • NSLayoutManager lays out text here
  66. 66. NSTextView • View for displaying/editing rich text • Contains NSTextContainer • NSLayoutManager lays out text here • Lots of methods ready to be wired up in IB
  67. 67. NSTextView • View for displaying/editing rich text • Contains NSTextContainer • NSLayoutManager lays out text here • Lots of methods ready to be wired up in IB • IB even has prebuilt menus to use them
  68. 68. Customizing NSTextView
  69. 69. Customizing NSTextView • First stop - delegate methods
  70. 70. Customizing NSTextView • First stop - delegate methods • From NSTextViewDelegate and NSTextDelegate protocols
  71. 71. Customizing NSTextView • First stop - delegate methods • From NSTextViewDelegate and NSTextDelegate protocols • Last stop - subclass
  72. 72. NSTextField
  73. 73. NSTextField • Lighter weight than NSTextView
  74. 74. NSTextField • Lighter weight than NSTextView • Subclass of NSControl, not NSText
  75. 75. NSTextField • Lighter weight than NSTextView • Subclass of NSControl, not NSText • Generally single line
  76. 76. NSTextField • Lighter weight than NSTextView • Subclass of NSControl, not NSText • Generally single line • No layout manager or text container
  77. 77. UITextView
  78. 78. UITextView • Much simpler than NSTextView
  79. 79. UITextView • Much simpler than NSTextView • 10 properties and 2 methods
  80. 80. UITextView • Much simpler than NSTextView • 10 properties and 2 methods • vs. NSTextView/NSText’s 258 methods
  81. 81. UITextView • Much simpler than NSTextView • 10 properties and 2 methods • vs. NSTextView/NSText’s 258 methods • Limited simple styling
  82. 82. UITextView • Much simpler than NSTextView • 10 properties and 2 methods • vs. NSTextView/NSText’s 258 methods • Limited simple styling • a few non-ranged attributes
  83. 83. UITextView • Much simpler than NSTextView • 10 properties and 2 methods • vs. NSTextView/NSText’s 258 methods • Limited simple styling • a few non-ranged attributes • Apple recommends UIWebView for complex styling
  84. 84. NSAttributedString on iOS
  85. 85. NSAttributedString on iOS • Available on iOS 3.2+
  86. 86. NSAttributedString on iOS • Available on iOS 3.2+ • For use with Core Text
  87. 87. NSAttributedString on iOS • Available on iOS 3.2+ • For use with Core Text • No AppKit Additions
  88. 88. NSAttributedString on iOS • Available on iOS 3.2+ • For use with Core Text • No AppKit Additions • Use Core Text attributes
  89. 89. Demo

Notes de l'éditeur



















































































































































































×