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.