Class: MotionWizard::IndexItem
- Inherits:
-
UIView
- Object
- UIView
- MotionWizard::IndexItem
- Defined in:
- lib/motion-wizard/views/index_item_view.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#label_wrapper ⇒ Object
readonly
Returns the value of attribute label_wrapper.
Instance Method Summary collapse
- #create_label ⇒ Object
- #create_label_wrapper ⇒ Object
- #init ⇒ Object
- #initialize_callbacks ⇒ Object
- #select ⇒ Object
- #unselect ⇒ Object
- #when_selected(&block) ⇒ Object
- #when_unselected(&block) ⇒ Object
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 3 def label @label end |
#label_wrapper ⇒ Object (readonly)
Returns the value of attribute label_wrapper.
3 4 5 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 3 def label_wrapper @label_wrapper end |
Instance Method Details
#create_label ⇒ Object
16 17 18 19 20 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 16 def create_label @label = UILabel.alloc.init @label.textAlignment = NSTextAlignmentCenter @label.origin = [0, 0] end |
#create_label_wrapper ⇒ Object
22 23 24 25 26 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 22 def create_label_wrapper @label_wrapper = UIView.alloc.init @label_wrapper.origin = [0, 0] @label_wrapper.backgroundColor = UIColor.clearColor end |
#init ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 5 def init super create_label create_label_wrapper @label_wrapper.addSubview(@label) addSubview(@label_wrapper) initialize_callbacks self end |
#initialize_callbacks ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 28 def initialize_callbacks when_selected do @original_text = @label.text @label.text = "[#{@label.text}]" end when_unselected { @label.text = @original_text} end |
#select ⇒ Object
45 46 47 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 45 def select @when_selected.call end |
#unselect ⇒ Object
49 50 51 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 49 def unselect @when_unselected.call end |
#when_selected(&block) ⇒ Object
37 38 39 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 37 def when_selected(&block) @when_selected = block end |
#when_unselected(&block) ⇒ Object
41 42 43 |
# File 'lib/motion-wizard/views/index_item_view.rb', line 41 def when_unselected(&block) @when_unselected = block end |