Ios 将转换视图添加到UIWindow或UIView后出现错误帧
以下代码将打破框架(这将是巨大的),如iOS 8.1.3所示Ios 将转换视图添加到UIWindow或UIView后出现错误帧,ios,objective-c,animation,uiview,uiwindow,Ios,Objective C,Animation,Uiview,Uiwindow,以下代码将打破框架(这将是巨大的),如iOS 8.1.3所示 someView.layer.transform = CGAffineTransformMakeScale(0.001f, 0.001f); [[[[UIApplication sharedApplication] keyWindow].subviews lastObject] addSubview:someView]; [UIView animateWithDuration:0.3f animations:^{ someV
someView.layer.transform = CGAffineTransformMakeScale(0.001f, 0.001f);
[[[[UIApplication sharedApplication] keyWindow].subviews lastObject] addSubview:someView];
[UIView animateWithDuration:0.3f animations:^{
someView.transform = CATransform3DIdentity;
}];
删除变换并用简单的帧运动动画替换它效果很好。为什么?经过一些调查和推理,我得出结论,在将someView添加到视图后应用它的转换可能是一个好主意。这就是解决办法。所以我们写:
[[[[UIApplication sharedApplication] keyWindow].subviews lastObject] addSubview:someView];
someView.layer.transform = CGAffineTransformMakeScale(0.001f, 0.001f);
[UIView animateWithDuration:0.3f animations:^{
someView.transform = CGAffineTransformIdentity;
}];
这和预期的一样