Module: UnderOs::UI::Style::Fonts

Included in:
UnderOs::UI::Style
Defined in:
lib/under_os/ui/style/fonts.rb

Instance Method Summary collapse

Instance Method Details

#fontFamilyObject



8
9
# File 'lib/under_os/ui/style/fonts.rb', line 8

def fontFamily
end

#fontFamily=(value) ⇒ Object



11
12
13
# File 'lib/under_os/ui/style/fonts.rb', line 11

def fontFamily=(value)
  @view.font = @view.font.fontWithName(value)
end

#fontSizeObject



15
16
# File 'lib/under_os/ui/style/fonts.rb', line 15

def fontSize
end

#fontSize=(value) ⇒ Object



18
19
20
21
# File 'lib/under_os/ui/style/fonts.rb', line 18

def fontSize=(value)
  @view.font  = @view.font.fontWithSize(value)
  @view.sizeToFit if @type == :icon
end

#textAlignObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/under_os/ui/style/fonts.rb', line 23

def textAlign
  if @view.is_a?(UIButton)
    case @view.contentHorizontalAlignment
      when UIControlContentHorizontalAlignmentRight  then 'right'
      when UIControlContentHorizontalAlignmentCenter then 'center'
      when UIControlContentHorizontalAlignmentFill   then 'justify'
      else                                                'left'
    end
  elsif @view.respond_to?(:textAlignment)
    case @view.textAlignment
      when NSTextAlignmentRight     then 'right'
      when NSTextAlignmentCenter    then 'center'
      when NSTextAlignmentJustified then 'justify'
      else                               'left'
    end
  end
end

#textAlign=(value) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/under_os/ui/style/fonts.rb', line 41

def textAlign=(value)
  if @view.is_a?(UIButton)
    @view.contentHorizontalAlignment = case value.to_s
      when 'right'   then UIControlContentHorizontalAlignmentRight
      when 'center'  then UIControlContentHorizontalAlignmentCenter
      when 'justify' then UIControlContentHorizontalAlignmentFill
      else                UIControlContentHorizontalAlignmentLeft
    end
  elsif @view.respond_to?(:textAlignment)
    @view.textAlignment = case value.to_s
      when 'right'   then NSTextAlignmentRight
      when 'center'  then NSTextAlignmentCenter
      when 'justify' then NSTextAlignmentJustified
      else                NSTextAlignmentLeft
    end
  end
end