iOS 自定义backBarButtonItem leftBarButtonItem

本文介绍了在iOS开发中自定义`backBarButtonItem`时遇到的问题,官方文档建议不要为`backBarButtonItem`设置custom view,因为会被忽略。通常错误的做法会被一些开发者误用。正确的做法是使用`leftBarButtonItem`,但需要注意在iOS6和iOS7之间存在10像素的显示偏差。文章提供了相应的解决方案代码。
摘要由CSDN通过智能技术生成

1. backBarButtonItem 


根据官方文档,Discussion里:

When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.

译文:当你自定义你的BarButtonItem时,不要将Custom View赋值给它(即BackBarButtonItem)。当你对BackBarButtonItem赋了值时,导航的项(Item)会忽略掉CustomView。

所以,我们没法按照老样子,像下面这样,给BackBarButtonItem赋值:

-(void) showBackBtn:(BOOL) bShow{
    if(bShow){
        UIImage* barImg = [UIImage imageNamed:@"DirectionalArrow_phone"];
	UIButton* btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 44)];
	[btn setIma
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值