From 65fabf49d70c6afc9985cbb2d4eac4e37380c3e9 Mon Sep 17 00:00:00 2001 From: appleguy Date: Sun, 20 Aug 2017 03:17:46 -0700 Subject: [PATCH] [ASImageNode] Enable .clipsToBounds by default (fix .cornerRadius, GIFs overflow). (#466) * [ASImageNode] Enable .clipsToBounds by default (fix .cornerRadius, GIFs overflow). We've seen a number of bugs reported over time that .cornerRadius didn't work on ASNetworkImageNode. This wasn't much of a concern because cornerRadius is very inefficient anyway, and there are better ways to round corners, but it should certainly work. It turns out that clipsToBounds has been off for images, and this ultimately was behind another issue recently seen wehre decoded GIFs would spill outside the bounds area to overlap nearby content. Although there is some risk of behavior change from this, I think the risk is fairly small, and in most cases it will probably fix behaviors in a way that doesn't cause problems for the app. We should consider if this property should be on for all ASDisplayNodes, but for now it would be a great step to be confident it's on for all ASImageNodes. * Update changelog for ImageNode Clipping. --- CHANGELOG.md | 1 + Source/ASImageNode.mm | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a07d9188..078fa9e17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- [ASImageNode] Enabled .clipsToBounds by default, fixing the use of .cornerRadius and clipping of GIFs. [Scott Goodson](https://github.com/appleguy) [#466](https://github.com/TextureGroup/Texture/pull/466) - Fix an issue in layout transition that causes it to unexpectedly use the old layout [Huy Nguyen](https://github.com/nguyenhuy) [#464](https://github.com/TextureGroup/Texture/pull/464) - Add -[ASDisplayNode detailedLayoutDescription] property to aid debugging. [Adlai Holler](https://github.com/Adlai-Holler) [#476](https://github.com/TextureGroup/Texture/pull/476) - Fix an issue that causes calculatedLayoutDidChange being called needlessly. [Huy Nguyen](https://github.com/nguyenhuy) [#490](https://github.com/TextureGroup/Texture/pull/490) diff --git a/Source/ASImageNode.mm b/Source/ASImageNode.mm index d36509d56..dce952d2c 100644 --- a/Source/ASImageNode.mm +++ b/Source/ASImageNode.mm @@ -175,7 +175,8 @@ - (instancetype)init self.contentsScale = ASScreenScale(); self.contentMode = UIViewContentModeScaleAspectFill; self.opaque = NO; - + self.clipsToBounds = YES; + // If no backgroundColor is set to the image node and it's a subview of UITableViewCell, UITableView is setting // the opaque value of all subviews to YES if highlighting / selection is happening and does not set it back to the // initial value. With setting a explicit backgroundColor we can prevent that change.