ios 下自定义导航栏的BarButtonItem 会产生一些偏移问题,

解决方案: 通过新建一个系统的带固定距离的Item来调节你的Item

#define   IOS7_NAVI_SPACE   -10
}
    [self.navigationItem setLeftBarButtonItems:[self getBackBarButtonitem]];
} //返回按钮
-(NSArray *)getBackBarButtonitem{
    //自定义button
    UIButton *button=[[UIButton alloc] initWithFrame:CGRectMake(, , , )];
    //设置背景图片
    [button setBackgroundImage:[UIImage imageNamed:@"nav_left_btn_unselected.png"] forState:UIControlStateNormal];
    //设置文字
    [button setTitle:@"返回" forState:UIControlStateNormal];
    button.titleLabel.font=[UIFont systemFontOfSize:];
    //设置文字颜色
    [button setTintColor:[UIColor whiteColor]];
    //为TouchUpInside添加行为
    [button addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    //初始化一个BarbuttonItem
    UIBarButtonItem *Item=[[UIBarButtonItem alloc] initWithCustomView:button];
    
    //在初始化一个系统的带有固定距离的占位的BarButtonItem 占位用
    UIBarButtonItem *fixedSpace=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
    fixedSpace.width=IOS7_NAVI_SPACE;//设置宽度
// 把带固定距离的Item放在前面,调整距离
    return [[NSArray alloc] initWithObjects:fixedSpace,Item, nil];
}

最新文章

  1. 实体之间的关系【Entity Relationships】(EF基础系列篇9)
  2. POJ2342 树形dp
  3. MyBatis学习(二)、SQL语句映射文件(2)增删改查、参数、缓存
  4. 100114J
  5. 两款基于Jquery的图表插件
  6. ListView简单使用
  7. PL/SQL之--包
  8. Listview的闪烁问题
  9. linode空间lamp环境的搭建
  10. asp.net mvc让我告诉你请求从哪里来
  11. Visual Assist X 破解步骤
  12. %3A%2F%2F这样的叫什么码啊?
  13. 深度学习 Deep Learning UFLDL 最新 Tutorial 学习笔记 1:Linear Regression
  14. 鼠标点击 input,显示瞬间的边框颜色,对之修改与隐藏
  15. python基础操作
  16. Mybatis(1)
  17. cronatab周期性任务
  18. 【Android】[Problem]-"Waiting for target device to come online".
  19. 【swoole】使用swoole简单实现TCP服务
  20. [C++]数据结构-排序:插入排序之直接插入排序

热门文章

  1. 将cocos2dx项目从VS移植到Eclipse
  2. UPUPW PHP环境集成包
  3. 使用CURL出现certificate verify failed错误的解决方法
  4. POJ 3422 Kaka's Matrix Travels(最小费用最大流)
  5. PYTHON多进程编码结束之进程池POOL
  6. 【NOIP 2012 开车旅行】***
  7. [topcoder]FoxAndChess
  8. wcf教程
  9. BOM List demo
  10. Android开发之BroadcastReceiver的使用