UINavigationBar BarButtonItem with Plain Style

前端 未结 8 2213
不思量自难忘°
不思量自难忘° 2020-12-14 09:19

i got the following code:

- (id)init {
  if (self = [super init]) {
      self.title = @\"please wait\";
      UIBarButtonItem *favorite = [[UIBarButtonItem          


        
8条回答
  •  不思量自难忘°
    2020-12-14 09:32

    Create a UIButton in interface builder, make it look like exactly what you want. Create an outlet for in in your .h:

    IBOutlet UIButton * _myButton;
    

    Then set it as your right bar button item using a custom view, which will eliminate the border:

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

    This works because UIButton is a subclass of UIView.

提交回复
热议问题