self.infoVIEwController.vIEw.Alpha = 0.0;[self.navigationController presentModalVIEwController:self.infoVIEwController animated:NO];[UIVIEw animateWithDuration:0.5 animations:^{self.infoVIEwController.vIEw.Alpha = 1.0;}];
但是我不能让它淡出,我已经尝试了几件事情,这是最新的,我试过不行:
- (IBAction)dismissAction:(ID)sender{if ([[self parentVIEwController] respondsToSelector:@selector(dismissModalVIEwControllerAnimated:)]){ [[self parentVIEwController] dismissModalVIEwControllerAnimated:YES]; self.parentVIEwController.modalTransitionStyle = UIModalTransitionStyleCrossdissolve; self.parentVIEwController.vIEw.Alpha = 0.0; [UIVIEw animateWithDuration:0.5 animations:^{self.parentVIEwController.vIEw.Alpha = 1.0;}];} else { [[self presentingVIEwController] dismissVIEwControllerAnimated:YES completion:nil]; self.presentedVIEwController.modalTransitionStyle = UIModalTransitionStyleCrossdissolve; self.presentedVIEwController.vIEw.Alpha = 0.0; [UIVIEw animateWithDuration:0.5 animations:^{ self.presentedVIEwController.vIEw.Alpha = 1.0;}];}
}
模态视图控制器淡出,但立即,而不是在它显示的时间段.
解决方法 这(原始部分)不是要从H2CO3的正确答案中夺走. UIModalTransitionStyleCrossdissolve完全符合您要查找的效果.你直到迟到才会设置modalTransitionStyle.将这些功能的所有代码替换为各自的位置:-(voID)show{ self.infoVIEwController.modalTransitionStyle = UIModalTransitionStyleCrossdissolve; [self presentModalVIEwController:self.infoVIEwController animated:YES];}- (IBAction)dismissAction:(ID)sender{ [self dismissModalVIEwControllerAnimated:YES];}
编辑响应时间是一个问题:我们来讨论违规代码.我们将专注于真正的部分,因为它基本上与其他部分完全相同.
[[self parentVIEwController] dismissModalVIEwControllerAnimated:YES];self.parentVIEwController.modalTransitionStyle = UIModalTransitionStyleCrossdissolve;self.parentVIEwController.vIEw.Alpha = 0.0;[UIVIEw animateWithDuration:0.5 animations:^{self.parentVIEwController.vIEw.Alpha = 1.0;}];
如果你正在寻找一个互惠的动画,这不是它.在您的原始动画中,将下一个视图的Alpha设置为0,然后呈现下一个视图控制器,然后将其视图的Alpha设置为1.因此,逻辑上,您需要在动画后关闭视图控制器;这很容易使用块.代码看起来像这样:
[UIVIEw animateWithDuration:0.5 animations:^{ self.vIEw.Alpha = 0;} completion:^(BOol b){ [self.presentingVIEwController dismissModalVIEwControllerAnimated:NO]; self.vIEw.Alpha = 1;}];
这行代码将视图的Alpha值设为0,然后(完成后)会关闭所显示的视图控制器,并将视图的Alpha设置为1.这是一个互动动画.
总结以上是内存溢出为你收集整理的ios – 如何解除模糊的VC与淡出动画?全部内容,希望文章能够帮你解决ios – 如何解除模糊的VC与淡出动画?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)