Class: UnderOS::UI::Button

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/button.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Button

Returns a new instance of Button.



4
5
6
7
8
9
10
11
# File 'lib/under_os/ui/button.rb', line 4

def initialize(options={})
  super

  self.text  = options.delete(:text) || ''
  @_.showsTouchWhenHighlighted = true
  @_.setBackgroundImage(options.delete(:image), forState:UIControlStateNormal) if options[:image]
  @_.sizeToFit
end

Instance Method Details

#textObject



13
14
15
# File 'lib/under_os/ui/button.rb', line 13

def text
  @_.currentTitle
end

#text=(new_text, state = UIControlStateNormal) ⇒ Object



17
18
19
20
# File 'lib/under_os/ui/button.rb', line 17

def text=(new_text, state=UIControlStateNormal)
  @_.setTitle new_text, forState:state
  repaint
end