0

CATransform3DMakeRotation Setting AnchorPoint and position iOS7 View position error...但是iOS8和iOS9没有这个问题..为什么?


-(void)viewDidAppear:(BOOL)animated
{

[self setAnchorPoint:CGPointMake(0.5, 1) forView:self.chieldImageView];

}

-(void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view
{

CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x,
                               view.bounds.size.height * anchorPoint.y);

CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x,
                               view.bounds.size.height * view.layer.anchorPoint.y);

newPoint = CGPointApplyAffineTransform(newPoint, view.transform);
oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);

CGPoint position = view.layer.position;

position.x -= oldPoint.x;
position.x += newPoint.x;

position.y -= oldPoint.y;
position.y += newPoint.y;

view.layer.position = position;
view.layer.anchorPoint = anchorPoint;
}
4

1 回答 1

0

这可能是由于使用了自动布局,在 iOS8 和主要他们修复了它。
没有这么多的解决方案,一种是将要转换的视图保留在容器视图中。您使用容器视图上的约束来定位它,并且在包含的(需要转换的视图)中,您只需将其添加为子视图,方法是保持-translatesAutoresizingMaskIntoConstraints为 YES。
检查马特

于 2015-09-28T07:40:28.123 回答