mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 17:52:17 +08:00
Merge pull request #122 from squidpunch/add-color-setter
Add color setter
This commit is contained in:
@@ -14,6 +14,7 @@ module RubyMotionQuery
|
||||
def text_color ; view.textColor ; end
|
||||
def text_color=(v) ; view.textColor = v ; end
|
||||
alias :color :text_color
|
||||
alias :color= :text_color=
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
51
spec/stylers/ui_text_view_styler_spec.rb
Normal file
51
spec/stylers/ui_text_view_styler_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
describe 'stylers/ui_text_view' do
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
def ui_text_view_kitchen_sink(st)
|
||||
st.text = 'foo'
|
||||
st.font = font.system(12)
|
||||
st.text_color= color.red
|
||||
end
|
||||
|
||||
def ui_text_view_attributed_string(st)
|
||||
st.attributed_text = NSAttributedString.alloc.initWithString("RMQ")
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@view_klass = UITextView
|
||||
end
|
||||
|
||||
behaves_like "styler"
|
||||
|
||||
it 'should apply a style with every UITextViewStyler wrapper method' do
|
||||
view = @vc.rmq.append(@view_klass, :ui_text_view_kitchen_sink).get
|
||||
|
||||
view.tap do |v|
|
||||
view.text.should == "foo"
|
||||
view.font.should == UIFont.systemFontOfSize(12)
|
||||
view.textColor.should == UIColor.redColor
|
||||
end
|
||||
end
|
||||
|
||||
it "applies an attributed string" do
|
||||
view = @vc.rmq.append(@view_klass, :ui_text_view_attributed_string).get
|
||||
|
||||
view.tap do |v|
|
||||
v.text.should == 'RMQ'
|
||||
end
|
||||
end
|
||||
|
||||
it "can also set the color using the 'color' alias" do
|
||||
view = @vc.rmq.append(@view_klass, :ui_text_view_kitchen_sink).get
|
||||
|
||||
rmq(view).style do |st|
|
||||
st.color = rmq.color.green
|
||||
end
|
||||
|
||||
view.tap do |v|
|
||||
view.textColor.should == UIColor.greenColor
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user