From 8164d63d29e1ff4fd25de0f34b205769e789b99c Mon Sep 17 00:00:00 2001 From: Nadine Salter Date: Fri, 20 Mar 2015 12:26:29 -0700 Subject: [PATCH] Fix ASTextNode positioning for non-left alignment, part deux. Apply the fix from #329 to `-setFrame:`. Fixes #89. --- AsyncDisplayKit/ASTextNode.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AsyncDisplayKit/ASTextNode.mm b/AsyncDisplayKit/ASTextNode.mm index 5a61451ffe..106fc6fa8a 100644 --- a/AsyncDisplayKit/ASTextNode.mm +++ b/AsyncDisplayKit/ASTextNode.mm @@ -234,6 +234,18 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f) } } +- (void)setFrame:(CGRect)frame +{ + [super setFrame:frame]; + if (!CGSizeEqualToSize(frame.size, _constrainedSize)) { + // Our bounds have changed to a size that is not identical to our constraining size, + // so our previous layout information is invalid, and TextKit may draw at the + // incorrect origin. + _constrainedSize = CGSizeMake(-INFINITY, -INFINITY); + [self _invalidateRenderer]; + } +} + - (void)setBounds:(CGRect)bounds { [super setBounds:bounds];