自定义导航栏上的button

UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    btn1.frame = CGRectMake(0, 0, 30, 34);

    [btn1 addTarget:self action:@selector(navBtnPress:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn1];


创建一个button ,然后用它去初始化UIBarButtonItem.

你可能感兴趣的:(自定义导航栏上的button)