UIBarButtonItem左右按钮的自定义

- (void)viewDidLoad

{

    [superviewDidLoad];

    [self.navigationControllersetNavigationBarHidden:NO];

    self.title = @"完善信息";

    /*

     * @ 一个导航控制器控制着若干个视图控制器

     *   一个导航控制器包含一个NavigationBar和一个toolBar

     *   NavigationBar中的"按钮"是一个UINavigationItemonly one

     *   通过设置UINavigationItem的属性,显示ItemUInavigatinBar

     *   UINavigationItem不是由navigationBar控制,更不由UInavigtaionController来控制

     *   而是由当前的视图控制器控制

     */

    UIButton *skipItem = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    [skipItem setTitle:@"跳过"forState:UIControlStateNormal];

    [skipItem setFrame:CGRectMake(0, 0, 60, 35)];

    [skipItem addTarget:selfaction:@selector(skip_action) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:skipItem];

    self.navigationItem.leftBarButtonItem = leftItem;

    

    UIButton *finishItem = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    [finishItem setTitle:@"完成"forState:UIControlStateNormal];

    [finishItem setFrame:CGRectMake(0, 0, 60, 35)];

    [finishItem addTarget:selfaction:@selector(finish_action) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:finishItem];

    self.navigationItem.rightBarButtonItem = rightItem;

 

}

你可能感兴趣的:(uibarbuttonitem)