From 1ce2c550935fa33a1ce6370eef63a62ba2cb932e Mon Sep 17 00:00:00 2001 From: Seb Hopley Date: Thu, 13 Nov 2014 15:49:37 +0000 Subject: [PATCH 1/3] Fix issue where image layer content remain When using in a UITableView fix issue where new layer content are added but not cleared out. --- UIImageViewAligned/UIImageViewAligned.m | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/UIImageViewAligned/UIImageViewAligned.m b/UIImageViewAligned/UIImageViewAligned.m index b0f332e..193c29b 100644 --- a/UIImageViewAligned/UIImageViewAligned.m +++ b/UIImageViewAligned/UIImageViewAligned.m @@ -20,7 +20,6 @@ - (id)initWithFrame:(CGRect)frame return self; } - - (id)initWithImage:(UIImage *)image { self = [super initWithImage:image]; @@ -182,17 +181,31 @@ - (CGSize)realContentSize #pragma mark - UIImageView overloads -- (void)setHighlighted:(BOOL)highlighted { +- (void)setHighlighted:(BOOL)highlighted +{ [super setHighlighted:highlighted]; self.layer.contents = nil; } +- (void)didMoveToWindow +{ + [super didMoveToSuperview]; + self.layer.contents = nil; +} + +- (void)didMoveToSuperview +{ + [super didMoveToSuperview]; + self.layer.contents = nil; +} + #pragma mark - Properties needed for Interface Builder - (BOOL)alignLeft { return (_alignment & UIImageViewAlignmentMaskLeft) != 0; } + - (void)setAlignLeft:(BOOL)alignLeft { if (alignLeft) @@ -205,6 +218,7 @@ - (BOOL)alignRight { return (_alignment & UIImageViewAlignmentMaskRight) != 0; } + - (void)setAlignRight:(BOOL)alignRight { if (alignRight) @@ -213,11 +227,11 @@ - (void)setAlignRight:(BOOL)alignRight self.alignment &= ~UIImageViewAlignmentMaskRight; } - - (BOOL)alignTop { return (_alignment & UIImageViewAlignmentMaskTop) != 0; } + - (void)setAlignTop:(BOOL)alignTop { if (alignTop) @@ -230,6 +244,7 @@ - (BOOL)alignBottom { return (_alignment & UIImageViewAlignmentMaskBottom) != 0; } + - (void)setAlignBottom:(BOOL)alignBottom { if (alignBottom) From cb025894c251679b8192128d26b4fc3cd289f41a Mon Sep 17 00:00:00 2001 From: Seb Hopley Date: Thu, 13 Nov 2014 15:53:20 +0000 Subject: [PATCH 2/3] Revert "Fix issue where image layer content remain" This reverts commit 1ce2c550935fa33a1ce6370eef63a62ba2cb932e. --- UIImageViewAligned/UIImageViewAligned.m | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/UIImageViewAligned/UIImageViewAligned.m b/UIImageViewAligned/UIImageViewAligned.m index 193c29b..b0f332e 100644 --- a/UIImageViewAligned/UIImageViewAligned.m +++ b/UIImageViewAligned/UIImageViewAligned.m @@ -20,6 +20,7 @@ - (id)initWithFrame:(CGRect)frame return self; } + - (id)initWithImage:(UIImage *)image { self = [super initWithImage:image]; @@ -181,31 +182,17 @@ - (CGSize)realContentSize #pragma mark - UIImageView overloads -- (void)setHighlighted:(BOOL)highlighted -{ +- (void)setHighlighted:(BOOL)highlighted { [super setHighlighted:highlighted]; self.layer.contents = nil; } -- (void)didMoveToWindow -{ - [super didMoveToSuperview]; - self.layer.contents = nil; -} - -- (void)didMoveToSuperview -{ - [super didMoveToSuperview]; - self.layer.contents = nil; -} - #pragma mark - Properties needed for Interface Builder - (BOOL)alignLeft { return (_alignment & UIImageViewAlignmentMaskLeft) != 0; } - - (void)setAlignLeft:(BOOL)alignLeft { if (alignLeft) @@ -218,7 +205,6 @@ - (BOOL)alignRight { return (_alignment & UIImageViewAlignmentMaskRight) != 0; } - - (void)setAlignRight:(BOOL)alignRight { if (alignRight) @@ -227,11 +213,11 @@ - (void)setAlignRight:(BOOL)alignRight self.alignment &= ~UIImageViewAlignmentMaskRight; } + - (BOOL)alignTop { return (_alignment & UIImageViewAlignmentMaskTop) != 0; } - - (void)setAlignTop:(BOOL)alignTop { if (alignTop) @@ -244,7 +230,6 @@ - (BOOL)alignBottom { return (_alignment & UIImageViewAlignmentMaskBottom) != 0; } - - (void)setAlignBottom:(BOOL)alignBottom { if (alignBottom) From a07b3d55cae251cba6e68a0e913f51c0904e54f6 Mon Sep 17 00:00:00 2001 From: Seb Hopley Date: Thu, 13 Nov 2014 15:55:29 +0000 Subject: [PATCH 3/3] Fix issue where image layer contents remain When using in a UITableView fix issue where new layer content are added but not cleared out. --- UIImageViewAligned/UIImageViewAligned.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/UIImageViewAligned/UIImageViewAligned.m b/UIImageViewAligned/UIImageViewAligned.m index b0f332e..e97d95d 100644 --- a/UIImageViewAligned/UIImageViewAligned.m +++ b/UIImageViewAligned/UIImageViewAligned.m @@ -187,6 +187,20 @@ - (void)setHighlighted:(BOOL)highlighted { self.layer.contents = nil; } +#pragma mark - UIView overloads + +- (void)didMoveToWindow +{ + [super didMoveToWindow]; + self.layer.contents = nil; +} + +- (void)didMoveToSuperview +{ + [super didMoveToSuperview]; + self.layer.contents = nil; +} + #pragma mark - Properties needed for Interface Builder - (BOOL)alignLeft