mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-29 09:01:05 +00:00
Merge pull request #488 from facebook/CleanupFrameSetter
Clean up logic in setFrame: for clarity and compactness
This commit is contained in:
commit
c271462b16
@ -143,20 +143,21 @@
|
|||||||
ASDisplayNodeAssert(CATransform3DIsIdentity(self.transform), @"Must be an identity transform");
|
ASDisplayNodeAssert(CATransform3DIsIdentity(self.transform), @"Must be an identity transform");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_layer && ASDisplayNodeThreadIsMain()) {
|
BOOL useLayer = (_layer && ASDisplayNodeThreadIsMain());
|
||||||
CGPoint oldBoundsOrigin = _layer.bounds.origin;
|
|
||||||
_layer.bounds = CGRectMake(oldBoundsOrigin.x, oldBoundsOrigin.y, rect.size.width, rect.size.height);
|
CGPoint origin = (useLayer ? _layer.bounds.origin : self.bounds.origin);
|
||||||
|
CGPoint anchorPoint = (useLayer ? _layer.anchorPoint : self.anchorPoint);
|
||||||
CGPoint anchorPoint = _layer.anchorPoint;
|
|
||||||
_layer.position = CGPointMake(rect.origin.x + rect.size.width * anchorPoint.x,
|
CGRect bounds = (CGRect){ origin, rect.size };
|
||||||
rect.origin.y + rect.size.height * anchorPoint.y);
|
CGPoint position = CGPointMake(rect.origin.x + rect.size.width * anchorPoint.x,
|
||||||
|
rect.origin.y + rect.size.height * anchorPoint.y);
|
||||||
|
|
||||||
|
if (useLayer) {
|
||||||
|
_layer.bounds = bounds;
|
||||||
|
_layer.position = position;
|
||||||
} else {
|
} else {
|
||||||
CGPoint oldBoundsOrigin = self.bounds.origin;
|
self.bounds = bounds;
|
||||||
self.bounds = CGRectMake(oldBoundsOrigin.x, oldBoundsOrigin.y, rect.size.width, rect.size.height);
|
self.position = position;
|
||||||
|
|
||||||
CGPoint anchorPoint = self.anchorPoint;
|
|
||||||
self.position = CGPointMake(rect.origin.x + rect.size.width * anchorPoint.x,
|
|
||||||
rect.origin.y + rect.size.height * anchorPoint.y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user