From 3589bd7ca0d122fe06792868485d79c622a3f47d Mon Sep 17 00:00:00 2001 From: Grant Paul Date: Sat, 29 Oct 2016 22:01:30 -0700 Subject: [PATCH] Set frame on the content view, rather than layer, for autolayout. Autolayout requires using the UIView geometry methods for changes to be correctly propagated. Use that for the shimmering content view. --- FBShimmering/FBShimmeringView.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/FBShimmering/FBShimmeringView.m b/FBShimmering/FBShimmeringView.m index 5dcf247..188c11c 100644 --- a/FBShimmering/FBShimmeringView.m +++ b/FBShimmering/FBShimmeringView.m @@ -59,4 +59,15 @@ - (void)setContentView:(UIView *)contentView } } +- (void)layoutSubviews +{ + // Autolayout requires these to be set on the UIView, not the CALayer. + // Do this *before* the layer has a chance to set the properties, as the + // setters would be ignored (even for autolayout) if set to the same value. + _contentView.bounds = self.bounds; + _contentView.center = self.center; + + [super layoutSubviews]; +} + @end