present 出一个半透明的viewcontroller
NavigationController * nav = [[NavigationController alloc] initWithRootViewController:aViewController];if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
nav.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
nav.modalPresentationStyle=UIModalPresentationOverCurrentContext;
}else{
nav.modalPresentationStyle=UIModalPresentationCurrentContext;
}
[self presentViewController:nav animated:YES completion:nil];
或者是模拟present的动画 push出新的viewcontroller
CATransition* transition = [CATransitionanimation];
transition.duration =0.4f;
transition.type =kCATransitionMoveIn;
transition.subtype =kCATransitionFromTop;
[self.navigationController.view.layeraddAnimation:transition forKey:kCATransition];
[self.navigationControllerpushViewController:aViewControlleranimated:NO];
退回的时候的动画
CATransition* transition = [CATransitionanimation];
transition.duration =0.4f;
transition.type =kCATransitionReveal;
transition.subtype =kCATransitionFromBottom;
[self.navigationController.view.layeraddAnimation:transition forKey:kCATransition];
[self.navigationControllerpopViewControllerAnimated:NO];
还要透明的话 只能在当前页面抓个图了
- (UIImage *)capture
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(MainScreenWidth,kTopBackgroundImageViewHeight), self.view.opaque,0.0);
[self.navigationController.view.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage * img =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
把这个image 设置为推出来viewcontrolleer 的最上层iamgeview的backimageview,再设个透明度就能搞定了