mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 09:33:43 +08:00
Adds attributed_title and attributed_title_highlighted to UIButton styler.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user