Skip to content

Commit

Permalink
* [ios] fix bug that setFrame incorrectly when transform has been set
Browse files Browse the repository at this point in the history
From the UIView's frame documentation:
https://developer.apple.com/reference/uikit/uiview#//apple_ref/occ/instp/UIView/frame
Warning : If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
So layer's transform must be reset to CATransform3DIdentity before setFrame, otherwise frame will be incorrect
  • Loading branch information
cxfeng1 committed Dec 7, 2016
1 parent bfd16a0 commit 84dfd4c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,24 @@ - (void)_frameDidCalculated:(BOOL)isChanged

if ([self isViewLoaded] && isChanged && [self isViewFrameSyncWithCalculated]) {

__weak typeof(self) weakSelf = self;
[self.weexInstance.componentManager _addUITask:^{
self.view.frame = _calculatedFrame;
if (_transform) {
_layer.transform = [[WXTransform new] getTransform:_transform withView:_view withOrigin:_transformOrigin];
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf->_transform && !CATransform3DEqualToTransform(strongSelf.layer.transform, CATransform3DIdentity)) {
// From the UIView's frame documentation:
// https://developer.apple.com/reference/uikit/uiview#//apple_ref/occ/instp/UIView/frame
// Warning : If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
// So layer's transform must be reset to CATransform3DIdentity before setFrame, otherwise frame will be incorrect
strongSelf.layer.transform = CATransform3DIdentity;
}

[self setNeedsDisplay];
strongSelf.view.frame = strongSelf.calculatedFrame;

if (strongSelf->_transform) {
strongSelf.layer.transform = [[WXTransform new] getTransform:strongSelf->_transform withView:strongSelf.view withOrigin:strongSelf->_transformOrigin];
}

[strongSelf setNeedsDisplay];
}];
}
}
Expand Down

0 comments on commit 84dfd4c

Please sign in to comment.