mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-29 05:05:36 +08:00
Added button stylers from sxross (https://github.com/sxross)
This commit is contained in:
@@ -45,6 +45,34 @@ module RubyMotionQuery
|
||||
@view.setBackgroundImage value, forState: UIControlStateHighlighted
|
||||
end
|
||||
|
||||
def border_color=(value)
|
||||
if value.is_a?(UICachedDeviceRGBColor)
|
||||
@view.layer.setBorderColor(value.CGColor)
|
||||
else
|
||||
@view.layer.setBorderColor value
|
||||
end
|
||||
end
|
||||
|
||||
def border_color
|
||||
@view.layer.borderColor
|
||||
end
|
||||
|
||||
def corner_radius=(value = 2)
|
||||
@view.layer.cornerRadius = value
|
||||
end
|
||||
|
||||
def corner_radius
|
||||
@view.layer.cornerRadius
|
||||
end
|
||||
|
||||
def border_width=(value)
|
||||
@view.layer.borderWidth = value
|
||||
end
|
||||
|
||||
def border_width
|
||||
@view.layer.borderWidth
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,5 +26,57 @@ describe 'stylers/ui_button' do
|
||||
# TODO
|
||||
1.should == 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "bordered button extensions" do
|
||||
before { @view = @vc.rmq.append(@view_klass, :ui_button_kitchen_sink) }
|
||||
|
||||
describe "border width" do
|
||||
before{ @view.style{|st| st.border_width = 2} }
|
||||
|
||||
it 'should be able to add a border to a button' do
|
||||
@view.get.layer.borderWidth.should == 2
|
||||
end
|
||||
|
||||
it "can get a border width for a button" do
|
||||
bw = nil
|
||||
@view.style{|st| bw = st.border_width}
|
||||
bw.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "corner radius" do
|
||||
before{ @view.style{|st| st.corner_radius = 10} }
|
||||
|
||||
it "sets the corner radius" { @view.get.layer.cornerRadius.should == 10 }
|
||||
it "gets the corner radius" do
|
||||
cr = nil
|
||||
@view.style{|st| cr = st.corner_radius}
|
||||
cr.should == 10
|
||||
end
|
||||
end
|
||||
|
||||
describe "border colors" do
|
||||
before{ @view.style{|st| st.border_color = rmq.color.blue} }
|
||||
|
||||
it "sets the correct number of color components" do
|
||||
CGColorGetNumberOfComponents(@view.get.layer.borderColor).should >= 4
|
||||
end
|
||||
|
||||
it "sets the right colors" do
|
||||
color = nil
|
||||
@view.style{|st| color = st.border_color}
|
||||
components = CGColorGetComponents(color)
|
||||
|
||||
# R=0, G=0, B=1 A=1
|
||||
|
||||
components[0].to_i.should == 0
|
||||
components[1].to_i.should == 0
|
||||
components[2].to_i.should == 1
|
||||
components[3].to_i.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user