Adds symbol capability for UIView contentModes

Closes #216
This commit is contained in:
Mark Rickert
2015-03-16 13:18:43 -04:00
parent d9615c0fb7
commit c4c3f4f376
2 changed files with 27 additions and 1 deletions

View File

@@ -92,6 +92,22 @@ module RubyMotionQuery
all: UITextAutocapitalizationTypeAllCharacters
}
CONTENT_MODE_TYPES = {
scale_to_fill: UIViewContentModeScaleToFill,
scale_aspect_fit: UIViewContentModeScaleAspectFit,
scale_aspect_fill: UIViewContentModeScaleAspectFill,
redraw: UIViewContentModeRedraw,
center: UIViewContentModeCenter,
top: UIViewContentModeTop,
bottom: UIViewContentModeBottom,
left: UIViewContentModeLeft,
right: UIViewContentModeRight,
top_left: UIViewContentModeTopLeft,
top_right: UIViewContentModeTopRight,
bottom_left: UIViewContentModeBottomLeft,
bottom_right: UIViewContentModeBottomRight
}
# When you create a styler, always inherit UIViewStyler
class UIViewStyler
def initialize(view)
@@ -272,7 +288,7 @@ module RubyMotionQuery
end
def content_mode=(value)
@view.setContentMode value
@view.setContentMode(CONTENT_MODE_TYPES[value] || value)
end
def content_mode
@view.contentMode

View File

@@ -57,6 +57,11 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
st.shadow_opacity = 0.5
st.shadow_path = UIBezierPath.bezierPathWithRect(st.view.bounds).CGPath
end
def ui_view_content_mode_symbol(st)
ui_view_kitchen_sink(st)
st.content_mode = :center
end
end
shared 'styler' do
@@ -340,6 +345,11 @@ describe 'ui_view_styler' do
view.layer.shadowPath.should == UIBezierPath.bezierPathWithRect(view.bounds).CGPath
end
it "should use symbols for content_mode" do
view = @vc.rmq.append(@view_klass, :ui_view_content_mode_symbol).get
view.contentMode.should == UIViewContentModeCenter
end
describe "background_gradient" do
before do
@view = UIView.alloc.init