Class: NSAttributedString
- Defined in:
- lib/ios/sugarcube-uikit/nsattributedstring.rb,
lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb
Instance Method Summary collapse
- #+(attributedstring) ⇒ Object
- #attrd(attributes = nil) ⇒ Object
- #background_color(value) ⇒ Object (also: #bg_color)
- #bold(size = nil) ⇒ Object
- #font(value) ⇒ Object
- #foreground_color(value) ⇒ Object (also: #color)
- #italic(size = nil) ⇒ Object
- #kern(value) ⇒ Object
- #letterpress ⇒ Object
- #ligature(value) ⇒ Object
- #nsattributedstring(attributes = nil) ⇒ Object
- #paragraph_style(value) ⇒ Object
- #shadow(value) ⇒ Object
- #strikethrough_style(value) ⇒ Object
- #stroke_color(value) ⇒ Object
- #stroke_width(value) ⇒ Object
- #sugarcube_nsattributedstring_dummy_method ⇒ Object
- #to_s ⇒ Object
- #uilabel ⇒ UILabel
- #underline ⇒ Object
- #underline_style(value) ⇒ Object
- #vertical_glyph_form(value) ⇒ Object
- #with_attributes(attributes) ⇒ Object
Instance Method Details
#+(attributedstring) ⇒ Object
161 162 163 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 161 def +(attributedstring) NSMutableAttributedString.alloc.initWithAttributedString(self) + attributedstring.nsattributedstring end |
#attrd(attributes = nil) ⇒ Object
157 158 159 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 157 def attrd(attributes=nil) self.nsattributedstring(attributes=nil) end |
#background_color(value) ⇒ Object Also known as: bg_color
106 107 108 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 106 def background_color(value) with_attributes({NSBackgroundColorAttributeName => value.uicolor}) end |
#bold(size = nil) ⇒ Object
75 76 77 78 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 75 def bold(size=nil) font = :bold.uifont(size) self.font(font) end |
#font(value) ⇒ Object
89 90 91 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 89 def font(value) with_attributes({NSFontAttributeName => value.uifont}) end |
#foreground_color(value) ⇒ Object Also known as: color
97 98 99 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 97 def foreground_color(value) with_attributes({NSForegroundColorAttributeName => value.uicolor}) end |
#italic(size = nil) ⇒ Object
80 81 82 83 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 80 def italic(size=nil) font = :italic.uifont(size) self.font(font) end |
#kern(value) ⇒ Object
115 116 117 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 115 def kern(value) with_attributes({NSKernAttributeName => value}) end |
#letterpress ⇒ Object
139 140 141 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 139 def letterpress with_attributes({NSTextEffectAttributeName => NSTextEffectLetterpressStyle}) end |
#ligature(value) ⇒ Object
111 112 113 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 111 def ligature(value) with_attributes({NSLigatureAttributeName => value}) end |
#nsattributedstring(attributes = nil) ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 149 def nsattributedstring(attributes=nil) if attributes.nil? self else self.with_attributes(attributes) end end |
#paragraph_style(value) ⇒ Object
93 94 95 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 93 def paragraph_style(value) with_attributes({NSParagraphStyleAttributeName => value}) end |
#shadow(value) ⇒ Object
131 132 133 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 131 def shadow(value) with_attributes({NSShadowAttributeName => value}) end |
#strikethrough_style(value) ⇒ Object
127 128 129 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 127 def strikethrough_style(value) with_attributes({NSStrikethroughStyleAttributeName => value}) end |
#stroke_color(value) ⇒ Object
123 124 125 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 123 def stroke_color(value) with_attributes({NSStrokeColorAttributeName => value.uicolor}) end |
#stroke_width(value) ⇒ Object
119 120 121 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 119 def stroke_width(value) with_attributes({NSStrokeWidthAttributeName => value}) end |
#sugarcube_nsattributedstring_dummy_method ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 45 def sugarcube_nsattributedstring_dummy_method # make sure NSAttributedString constants get compiled foo = NSFontAttributeName foo = NSParagraphStyleAttributeName foo = NSForegroundColorAttributeName foo = NSBackgroundColorAttributeName foo = NSLigatureAttributeName foo = NSKernAttributeName foo = NSStrikethroughStyleAttributeName foo = NSUnderlineStyleAttributeName foo = NSStrokeColorAttributeName foo = NSStrokeWidthAttributeName foo = NSShadowAttributeName foo = NSVerticalGlyphFormAttributeName # new iOS 7 text effects foo = NSTextEffectAttributeName foo = NSTextEffectLetterpressStyle # make sure alignments get compiled foo = NSLeftTextAlignment foo = NSRightTextAlignment foo = NSCenterTextAlignment foo = NSJustifiedTextAlignment foo = NSNaturalTextAlignment nil end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 71 def to_s string # this is the name of the Cocoa method to return an NSString end |
#uilabel ⇒ UILabel
4 5 6 7 8 9 10 |
# File 'lib/ios/sugarcube-uikit/nsattributedstring.rb', line 4 def uilabel UILabel.alloc.initWithFrame([[0, 0], [0, 0]]).tap do |label| label.attributedText = self label.backgroundColor = :clear.uicolor label.sizeToFit end end |
#underline ⇒ Object
85 86 87 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 85 def underline underline_style(NSUnderlineStyleSingle) end |
#underline_style(value) ⇒ Object
102 103 104 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 102 def underline_style(value) with_attributes({NSUnderlineStyleAttributeName => value}) end |
#vertical_glyph_form(value) ⇒ Object
135 136 137 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 135 def vertical_glyph_form(value) with_attributes({NSVerticalGlyphFormAttributeName => value}) end |
#with_attributes(attributes) ⇒ Object
143 144 145 146 147 |
# File 'lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb', line 143 def with_attributes(attributes) retval = NSMutableAttributedString.alloc.initWithAttributedString(self) retval.addAttributes(attributes, range:[0, self.length]) retval end |