Navigation返回按钮自定义

A-->B


B中设置:

#pragma mark-可以

    UIButton *backButton=[UIButton buttonWithType:UIButtonTypeCustom];

    backButton.frame=CGRectMake(0, 0, 30, 30);

    

    [backButton setBackgroundImage:[UIImage imageNamed:@"navigation_back@2x"] forState:UIControlStateNormal];

   

    UIBarButtonItem *back=[[UIBarButtonItem alloc]initWithCustomView:backButton];

    self.navigationItem.leftBarButtonItem=back;


A中设置:

#warning ------此处,只能设置文字,此法图片加上去无效

    

    UIBarButtonItem *backI=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"navigation_back@2x"] style:UIBarButtonItemStylePlain target:nil action:nil];

    self.navigationItem.backBarButtonItem=backI;


如此:

 UIBarButtonItem *back=[[UIBarButtonItem alloc]init];

  

//    back.image=[UIImage imageNamed:@"navigation_back@2x"];

    

    back.title=@"回去";


    self.navigationItem.backBarButtonItem=back;



你可能感兴趣的:(navigation返回)