prensent一个半透明的viewcontroller 或者push 出一个viewcontroller 做present 动画

1 篇文章 0 订阅
1 篇文章 0 订阅


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,再设个透明度就能搞定了 


    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值