diff --git a/motion/ruby_motion_query/stylers/ui_button_styler.rb b/motion/ruby_motion_query/stylers/ui_button_styler.rb index c46b70f..15af154 100644 --- a/motion/ruby_motion_query/stylers/ui_button_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_button_styler.rb @@ -6,7 +6,7 @@ module RubyMotionQuery @view.setTitle(value, forState: UIControlStateNormal) end def text - @view.title + @view.titleForState(UIControlStateNormal) end def attributed_text=(value) @@ -23,14 +23,14 @@ module RubyMotionQuery @view.setTitleColor(value, forState: UIControlStateNormal) end def color - @view.titleColor + @view.titleColorForState(UIControlStateNormal) end def color_highlighted=(value) @view.setTitleColor(value, forState: UIControlStateHighlighted) end def color_highlighted - @view.titleColorforState(UIControlStateHighlighted) + @view.titleColorForState(UIControlStateHighlighted) end def tint_color=(value) @@ -40,27 +40,41 @@ module RubyMotionQuery @view.tintColor end - def image=(value) - self.image_normal = value - end def image_normal=(value) @view.setImage value, forState: UIControlStateNormal end + def image_normal + @view.imageForState(UIControlStateNormal) + end + alias :image :image_normal + alias :image= :image_normal= def image_highlighted=(value) - @view.setImage value, forState: UIControlStateHighlighted + @view.setImage(value, forState: UIControlStateHighlighted) + end + def image_highlighted + @view.imageForState(UIControlStateHighlighted) end def background_image_normal=(value) - @view.setBackgroundImage value, forState: UIControlStateNormal + @view.setBackgroundImage(value, forState: UIControlStateNormal) + end + def background_image_normal + @view.backgroundImageForState(UIControlStateNormal) end def background_image_highlighted=(value) - @view.setBackgroundImage value, forState: UIControlStateHighlighted + @view.setBackgroundImage(value, forState: UIControlStateHighlighted) + end + def background_image_highlighted + @view.backgroundImageForState(UIControlStateHighlighted) end def background_image_selected=(value) - @view.setBackgroundImage value, forState: UIControlStateSelected + @view.setBackgroundImage(value, forState: UIControlStateSelected) + end + def background_image_selected + @view.backgroundImageForState(UIControlStateSelected) end def adjust_image_when_highlighted=(value) @@ -105,12 +119,11 @@ module RubyMotionQuery @view.imageEdgeInsets end - def text_highlighted value + def text_highlighted=(value) @view.setTitle(value, forState:UIControlStateHighlighted) end - - def text_highlighted= value - @view.setTitle(value, forState:UIControlStateHighlighted) + def text_highlighted + @view.titleForState(UIControlStateHighlighted) end def attributed_text_highlighted=(value) diff --git a/spec/stylers/ui_button_styler.rb b/spec/stylers/ui_button_styler.rb index 1c88463..f8118fe 100644 --- a/spec/stylers/ui_button_styler.rb +++ b/spec/stylers/ui_button_styler.rb @@ -51,14 +51,14 @@ describe 'stylers/ui_button' do rmq(view).style do |st| st.text.should == 'foo' st.attributed_text.should == NSAttributedString.alloc.initWithString("RMQ") - st.font.should == rmq.font.system(12) - st.color.should == rmq.color.red - st.color_highlighted.should == rmq.color.blue - st.image.should == rmq.image.resource('logo') - st.image_highlighted.should == rmq.image.resource('Icon') - st.background_image_normal.should == rmq.image.resource('Default') - st.background_image_highlighted.should == rmq.image.resource('logo') - st.background_image_selected.should == rmq.image.resource('Icon') + st.font.should == @vc.rmq.font.system(12) + st.color.should == @vc.rmq.color.red + st.color_highlighted.should == @vc.rmq.color.blue + st.image.should == @vc.rmq.image.resource('logo') + st.image_highlighted.should == @vc.rmq.image.resource('Icon') + st.background_image_normal.should == @vc.rmq.image.resource('Default') + st.background_image_highlighted.should == @vc.rmq.image.resource('logo') + st.background_image_selected.should == @vc.rmq.image.resource('Icon') st.text_highlighted.should == 'bar' st.attributed_text_highlighted.should == NSAttributedString.alloc.initWithString("RMQ Highlighted") st.adjust_image_when_highlighted.should == true @@ -73,7 +73,7 @@ describe 'stylers/ui_button' do describe "border width" do before{ @view.style{|st| st.border_width = 2} } - it 'should be able to add a border to a button' do + it "should be able to add a border to a button" do @view.get.layer.borderWidth.should == 2 end