将转换后的视图添加到 UIWindow 或 UIView 后出现错误的框架

Wrong frame after adding transformed view to UIWindow or UIView

下面的代码将破坏框架(这将是巨大的),如 iOS 8.1.3.

中所示
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;
}];

按预期工作。