Setting a UIImage to a UIBarButton item

前端 未结 2 1754
有刺的猬
有刺的猬 2021-01-28 07:45

I can\'t seem to add an image to this UIBarButtonItem without it crashing when touched:

 UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@\"         


        
2条回答
  •  暖寄归人
    2021-01-28 07:58

    You have to set the buttonStyle to custom not a UIBarButtonItemStylePlain

    and then [barbuttonitem setCustomView:anImageView];

提交回复
热议问题