自定义导航栏的返回按钮

来源:互联网 发布:凯撒和众信 知乎 编辑:程序博客网 时间:2024/05/16 11:23

/*

 获取左侧导航栏按钮

 */

- (void)customBackItems{

    

    UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

    [button setBackgroundImage:[UIImageimageNamed:@"Left_arrow"]

                      forState:UIControlStateNormal];

    [button addTarget:selfaction:@selector(callModalList)

     forControlEvents:UIControlEventTouchUpInside];

    button.frame =CGRectMake(5,5, 36,36);

    

    UIBarButtonItem *leftButton = [[UIBarButtonItemalloc] initWithCustomView:button];

    self.navigationItem.leftBarButtonItem = leftButton;

}


/*

 导航栏后退

 */

- (void)callModalList{

    NSLog(@"点击了左侧按钮");

    [self.navigationControllerpopViewControllerAnimated:YES];

}

0 0