总定义push,pop方向

萧树
2023-12-01


-(void) setUpBackBut{

    

    UIButton *backBut=[[UIButton alloc]init];

    

    [backBut setImage:[UIImage imageNamed:@"navgationbar_back_but"] forState:UIControlStateNormal];

    

    [backBut sizeToFit];

    

    [backBut addTarget:self action:@selector(backBUtClicked) forControlEvents:UIControlEventTouchUpInside];

    

    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backBut];

}


-(void) backBUtClicked{

    

    CATransition *anim=[CATransition animation];

    

    anim.type=kCATransitionPush;

    

    anim.subtype=kCATransitionFromRight;

    

    [self.navigationController.view.layer addAnimation:anim forKey:nil];

    

    [self.navigationController popViewControllerAnimated:YES];

    

}

 类似资料: