嗨,也许这是一个重复的问题,我只是不知道用来描述我的问题的关键字,如果是这种情况请指出。
我目前正在实现两个视图之间的转换,正如第二个视图所示,它应该看起来像是从外面放大到屏幕,有点落在屏幕上。我的想法是缩放第二个视图9 *原始大小并将原点放置到-original_width,-original_height,并将alpha设置为0.最后,我将alpha设置为1并显示原始大小。
因此以下代码无效,子视图未调整大小。任何人都可以告诉我我在这里想到的或者更好地向我展示一些执行任务的API吗?
[toVC.view setFrame:CGRectMake(0-fromVC.view.frame.size.width, 0-screenRect.size.height, fromVC.view.frame.size.width*3, fromVC.view.frame.size.height*3)];
for (UIView* view in toVC.view.subviews) {
CGRect frame = view.frame;
[view setFrame:CGRectMake(frame.origin.x*3, frame.origin.y*3, frame.size.width*3, frame.size.height*3)];
}
[toVC.view layoutIfNeeded];
[toVC.view setAlpha:0.1];
[UIView animateWithDuration:duration*5
animations:^{
[toVC.view setAlpha:1.0];
[toVC.view setFrame:CGRectMake(0, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height)];
for (UIView* view in toVC.view.subviews) {
CGRect frame = view.frame;
[view setFrame:CGRectMake(frame.origin.x/3, frame.origin.y/3, frame.size.width/3, frame.size.height/3)];
}
}
completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
答案 0 :(得分:0)
您可以在转换之前和之后设置视图转换:
CGAffineTransform scaleTransform = CGAffineTransformIdentity;
scaleTransform = CGAffineTransformScale(rotationTransform, 9., 9.);
view.transform = scaleTransform;
view.alpha = 0;
[UIView animateWithDuration:duration*5
animations:^{
view.transform = CGAffineTransformIdentity;
view.alpha = 1.;
}
}
completion:^(BOOL finished) {
}];