Module: UnderOs::UI::Style::Fonts
- Included in:
- UnderOs::UI::Style
- Defined in:
- lib/under_os/ui/style/fonts.rb
Constant Summary collapse
- BUTTONS_ALIGMENTS_MAP =
{ 'right' => UIControlContentHorizontalAlignmentRight, 'center' => UIControlContentHorizontalAlignmentCenter, 'justify' => UIControlContentHorizontalAlignmentFill, 'left' => UIControlContentHorizontalAlignmentLeft }
- TEXTNODES_ALIGMENTS_MAP =
{ 'right' => NSTextAlignmentRight, 'center' => NSTextAlignmentCenter, 'justify' => NSTextAlignmentJustified, 'left' => NSTextAlignmentLeft }
Instance Method Summary collapse
- #fontFamily ⇒ Object
- #fontFamily=(value) ⇒ Object
- #fontSize ⇒ Object
- #fontSize=(value) ⇒ Object
- #textAlign ⇒ Object
- #textAlign=(value) ⇒ Object
Instance Method Details
#fontFamily ⇒ Object
8 9 10 |
# File 'lib/under_os/ui/style/fonts.rb', line 8 def fontFamily @view.font.familyName end |
#fontFamily=(value) ⇒ Object
12 13 14 |
# File 'lib/under_os/ui/style/fonts.rb', line 12 def fontFamily=(value) @view.font = UIFont.fontWithName(value, size: @view.font.pointSize) end |
#fontSize ⇒ Object
16 17 18 |
# File 'lib/under_os/ui/style/fonts.rb', line 16 def fontSize @view.font.pointSize end |
#fontSize=(value) ⇒ Object
20 21 22 23 |
# File 'lib/under_os/ui/style/fonts.rb', line 20 def fontSize=(value) @view.font = @view.font.fontWithSize(value) @view.sizeToFit if @type == :icon end |
#textAlign ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/under_os/ui/style/fonts.rb', line 25 def textAlign if @view.is_a?(UIButton) BUTTONS_ALIGMENTS_MAP.key(@view.contentHorizontalAlignment) elsif @view.respond_to?(:textAlignment) TEXTNODES_ALIGMENTS_MAP.key(@view.textAlignment) end end |
#textAlign=(value) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/under_os/ui/style/fonts.rb', line 33 def textAlign=(value) if @view.is_a?(UIButton) @view.contentHorizontalAlignment = BUTTONS_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left'] elsif @view.respond_to?(:textAlignment) @view.textAlignment = TEXTNODES_ALIGMENTS_MAP[value.to_s] || BUTTONS_ALIGMENTS_MAP['left'] end end |