Class: UILabel

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-awesome/core_ext/ui_label.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#awesome_colorObject

Returns the value of attribute awesome_color.



2
3
4
# File 'lib/motion-awesome/core_ext/ui_label.rb', line 2

def awesome_color
  @awesome_color
end

Instance Method Details

#awesome?Boolean

Returns:

  • (Boolean)


4
# File 'lib/motion-awesome/core_ext/ui_label.rb', line 4

def awesome?; self.text =~ /\A\W/ end

#font=(font) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/motion-awesome/core_ext/ui_label.rb', line 6

def font=( font )      
  super
  return unless awesome?

  attr_text = self.attributedText
  attr_text.addAttribute( NSFontAttributeName, 
                          value:font, 
                          range:(2..attr_text.length-1) ) if attr_text.length > 1
  attr_text.addAttribute( NSFontAttributeName, 
                          value:MotionAwesome.font(font.pointSize), 
                          range:(0...1) )
  attr_text.addAttribute( NSForegroundColorAttributeName, 
                          value:awesome_color, 
                          range:(0...1) ) if awesome_color                        
end