Adds attributed_title and attributed_title_highlighted to UIButton styler.

This commit is contained in:
Mark Rickert
2015-03-20 12:13:08 -04:00
parent 4f91ccd170
commit 726c5a6b33
2 changed files with 18 additions and 0 deletions

View File

@@ -9,6 +9,13 @@ module RubyMotionQuery
@view.title
end
def attributed_text=(value)
@view.setAttributedTitle(value, forState: UIControlStateNormal)
end
def attributed_text
@view.attributedTitleForState(UIControlStateNormal)
end
def font=(value) ; @view.titleLabel.font = value ; end
def font ; @view.titleLabel.font ; end
@@ -106,6 +113,13 @@ module RubyMotionQuery
@view.setTitle(value, forState:UIControlStateHighlighted)
end
def attributed_text_highlighted=(value)
@view.setAttributedTitle(value, forState: UIControlStateHighlighted)
end
def attributed_text_highlighted
@view.attributedTitleForState(UIControlStateHighlighted)
end
end
end
end

View File

@@ -2,6 +2,7 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
def ui_button_kitchen_sink(st)
st.text = 'foo'
st.attributed_text = NSAttributedString.alloc.initWithString("RMQ")
st.font = font.system(12)
st.color = color.red
st.color_highlighted = color.blue
@@ -11,6 +12,7 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
st.background_image_highlighted = image.resource('logo')
st.background_image_selected = image.resource('Icon')
st.text_highlighted = 'bar'
st.attributed_text_highlighted = NSAttributedString.alloc.initWithString("RMQ Highlighted")
st.adjust_image_when_highlighted = true
st.selected = true
end
@@ -32,6 +34,8 @@ describe 'stylers/ui_button' do
view.tap do |v|
view.titleForState(UIControlStateNormal).should == "foo"
view.titleForState(UIControlStateHighlighted).should == 'bar'
view.attributedTitleForState(UIControlStateNormal).should == NSAttributedString.alloc.initWithString("RMQ")
view.attributedTitleForState(UIControlStateHighlighted).should == NSAttributedString.alloc.initWithString("RMQ Highlighted")
view.titleLabel.font.should == UIFont.systemFontOfSize(12)
view.titleColorForState(UIControlStateNormal).should == UIColor.redColor
view.titleColorForState(UIControlStateHighlighted).should == UIColor.blueColor