如何模态出一个半透明页面
一般在做自定义弹框时或者点击展示大图时用的较多。不说了上代码https://github.com/YST521/DEMOLIST.git//第一步A页面跳转到B页面 MOdalPopController * popVC = [MOdalPopController new]; popVC.view.backgroundColor = [UICol...
一般在做自定义弹框时或者点击展示大图时用的较多。不说了上代码https://github.com/YST521/DEMOLIST.git
//第一步A页面跳转到B页面
MOdalPopController * popVC = [MOdalPopController new];
popVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
popVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentAnimal]; //跳转动画
[self.navigationController presentViewController:popVC animated:NO completion:nil];
//
-(void)presentAnimal{
CATransition *animation = [CATransition animation];
animation.duration = 0.3;
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
[self.view.window.layer addAnimation:animation forKey:nil];
[self dismissViewControllerAnimated:NO completion:0];
}
//如果[self.navigationController presentViewController:popVC animated:NO completion:nil];里面动画为YES则是模态的那几种动画效果
B页面。dismiss 同样去掉了动画效果 重新添加了动画
-(void)dismiss{
CATransition *animation = [CATransition animation];
animation.duration = 0.3;
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
[self.view.window.layer addAnimation:animation forKey:nil];
[self dismissViewControllerAnimated:NO completion:0];
}
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)