如何在变换将当前视图缩放到 0.5 % 之前弹出父视图控制器以在背景绘制
我尝试
根据此代码对 popViewcontroller 进行变换比例动画,当它开始变换时,它会显示黑屏而不是父视图,
如何解决此问题?
[UIView animateWithDuration:0.5f
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
self.view.alpha = 1.0f;
self.view.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
} completion:^(BOOL finished) {
[[self navigationController] popViewControllerAnimated:NO];
}];
I'm try to popViewcontroller with transform scale animation
according this code when it begin transform it present the black screen instead of the Parent View
how to fix this ?
[UIView animateWithDuration:0.5f
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
self.view.alpha = 1.0f;
self.view.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
} completion:^(BOOL finished) {
[[self navigationController] popViewControllerAnimated:NO];
}];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是预期的行为,因为直到调用 popViewControllerAnimated: 方法并且在动画完成后调用它之前,前一个控制器的视图并不在视图层次结构中。
我不认为将子视图直接添加到导航控制器的视图是一个好主意,但以下代码应该适合您。
顺便说一句,
UIViewAnimationCurveEaseInOut
不是 options 参数的正确常量。对于此方法,您应该使用以UIViewAnimationOption
开头的常量。This is the expected behavior, because the view of the previous controller is not in the view hierarchy until
popViewControllerAnimated:
method is called and you call it after the animation finishes.I don't think adding subviews directly to the view of the navigation controller is a good idea, but the following code should work for you.
By the way,
UIViewAnimationCurveEaseInOut
is not a correct constant for the options parameter. You should use the constants that start withUIViewAnimationOption
for this method.