iOS:fix Transform situation when apply layout
This commit is contained in:
parent
f530256d05
commit
a9608506f5
@ -67,13 +67,11 @@ - (instancetype)init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)apply:(CGSize)frameSize {
|
- (void)apply:(CGSize)frameSize {
|
||||||
if (!CGAffineTransformEqualToTransform(self.view.transform, CGAffineTransformIdentity)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.resolved = NO;
|
self.resolved = NO;
|
||||||
[self measure:frameSize];
|
[self measure:frameSize];
|
||||||
[self layout];
|
[self layout];
|
||||||
[self setFrame];
|
[self setFrame];
|
||||||
|
self.resolved = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)apply {
|
- (void)apply {
|
||||||
@ -119,7 +117,6 @@ - (void)measure:(CGSize)targetSize {
|
|||||||
self.measuredWidth - self.paddingLeft - self.paddingRight,
|
self.measuredWidth - self.paddingLeft - self.paddingRight,
|
||||||
self.measuredHeight - self.paddingTop - self.paddingBottom)];
|
self.measuredHeight - self.paddingTop - self.paddingBottom)];
|
||||||
}
|
}
|
||||||
self.resolved = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)measureContent:(CGSize)targetSize {
|
- (void)measureContent:(CGSize)targetSize {
|
||||||
@ -163,26 +160,28 @@ - (void)layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)rect:(CGRect)rect1 equalTo:(CGRect)rect2 {
|
||||||
|
return ABS(rect1.origin.x - rect2.origin.x) < 0.00001f
|
||||||
|
&& ABS(rect1.origin.y - rect2.origin.y) < 0.00001f
|
||||||
|
&& ABS(rect1.size.width - rect2.size.width) < 0.00001f
|
||||||
|
&& ABS(rect1.size.height - rect2.size.height) < 0.00001f;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setFrame {
|
- (void)setFrame {
|
||||||
if (!CGAffineTransformEqualToTransform(self.view.transform, CGAffineTransformIdentity)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (self.layoutType != DoricUndefined) {
|
if (self.layoutType != DoricUndefined) {
|
||||||
[self.view.subviews forEach:^(__kindof UIView *obj) {
|
[self.view.subviews forEach:^(__kindof UIView *obj) {
|
||||||
[obj.doricLayout setFrame];
|
[obj.doricLayout setFrame];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
if (self.view.width != self.measuredWidth) {
|
CGRect originFrame = CGRectMake(self.measuredX, self.measuredY, self.measuredWidth, self.measuredHeight);
|
||||||
self.view.width = self.measuredWidth;
|
if (!CGAffineTransformEqualToTransform(self.view.transform, CGAffineTransformIdentity)) {
|
||||||
|
CGPoint anchor = self.view.layer.anchorPoint;
|
||||||
|
originFrame = CGRectOffset(originFrame, -anchor.x * self.measuredWidth - self.measuredX, -anchor.y * self.measuredHeight - self.measuredY);
|
||||||
|
originFrame = CGRectApplyAffineTransform(originFrame, self.view.transform);
|
||||||
|
originFrame = CGRectOffset(originFrame, anchor.x * self.measuredWidth + self.measuredX, anchor.y * self.measuredHeight + self.measuredY);
|
||||||
}
|
}
|
||||||
if (self.view.height != self.measuredHeight) {
|
if (![self rect:originFrame equalTo:self.view.frame]) {
|
||||||
self.view.height = self.measuredHeight;
|
self.view.frame = originFrame;
|
||||||
}
|
|
||||||
if (self.view.x != self.measuredX) {
|
|
||||||
self.view.x = self.measuredX;
|
|
||||||
}
|
|
||||||
if (self.view.y != self.measuredY) {
|
|
||||||
self.view.y = self.measuredY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user