Permalink
Browse files

Fix setting layer attributes crashes on struct values

  • Loading branch information...
1 parent d910e85 commit a9355440e2743256022def5dfc1415b99fbe56fb @seanhotw seanhotw committed Feb 14, 2013
Showing with 10 additions and 0 deletions.
  1. +1 −0 lib/simple_view/view_builder.rb
  2. +9 −0 spec/view_builder_spec.rb
@@ -141,6 +141,7 @@ def setValue value, forUndefinedKey: key
elsif key.end_with?('Image') || key.end_with?('image')
view.setValue value.to_image, forKey: key
elsif key == 'layer'
+ convert_primitives_to_objects_in_hash value
view.layer.setValuesForKeysWithDictionary value
else
view.setValue value, forKey: key
@@ -36,6 +36,15 @@
end
end
+ describe "#layer" do
+ it "should set layer attributes" do
+ view = SimpleView::ViewBuilder.view_for(UIView, layer: {borderWidth: 12, shadowOffset: CGSizeMake(2, 4)})
+ view.layer.borderWidth.should == 12
+ view.layer.shadowOffset.width.should == 2
+ view.layer.shadowOffset.height.should == 4
+ end
+ end
+
describe "#backgroundColor" do
it "should set backgroundColor by HTML code" do
view = SimpleView::ViewBuilder.view_for(UIView, backgroundColor: "#f00")

0 comments on commit a935544

Please sign in to comment.