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];
}

IOS7 自定义UIBarButtonItem 的一些问题的更多相关文章

  1. ios7 自定义UINavigationBar UIBarButtonItem 10px的偏移纠正

    为UINavigationBar 写一个分类.UINavigationItem+correct_offset.h  转载 http://www.colabug.com/thread-1112420-1 ...

  2. 自定义UIBarButtonItem

    如果是通过UIButton自定义UIBarButtonItem,那么通过如下这个方式设置title是无效的.必须要直接给button设置title. self.navigationItem.right ...

  3. iOS7自定义back按钮和pop交互手势

    Clambake for iPhone有一个回退按钮在所有的导航条上.这是一个简单的没有文字箭头. 实现一个自定义按钮是简单的.类似这个设置controller 的navigationItem一个le ...

  4. 第十篇、自定义UIBarButtonItem和UIButton block回调

    // 自定义导航栏左边按钮 self.navigationItem.leftBarButtonItem = [JQBlockedBarButtonItem blockedBarButtonItemWi ...

  5. IOS7学习之路九(ios7自定义UIAlertView)

    IOS7的UIAlertView 不支持自定义,无法添加subview . 不过可以用第三方库git上的下载链接    https://github.com/wimagguc/ios-custom-a ...

  6. iOS7自定义statusbar和navigationbar的若干问题

    当然有许多问题是这篇文章中没有提到的,按照文章的方法进行设置,你可能会遇到以下问题: 1.navigationbar的背景图片自定义以后,statusbar虽然和navigationbar共用了背景图 ...

  7. ios7自定义返回按钮后,右滑返回功能失效解决方法

    -(void)viewWillAppear:(BOOL)animated{     [super viewWillAppear:animated];     //开启ios右滑返回     if ([ ...

  8. IOS7 UI Transition Guide 状态栏 statusbar

    本文转载至 http://blog.csdn.net/linzhiji/article/details/12233387 Redesign Your App for iOS 7 之 页面布局 iOS7 ...

  9. iOS UIBarButtonItem 固定尺寸

    自定义UIBarButtonItem的时候发现 有时候UIBarButtonItem尺寸会发生变化 通过以下方式可以很好的解决问题 [button.widthAnchor constraintEqua ...

随机推荐

  1. 1012: [JSOI2008]最大数maxnumber

    单点更新,区间求最大值的题: 可以使用树状数组和线段树: #include<cstdio> #include<cstring> #include<algorithm> ...

  2. [水题]Codeforces337A Puzzles

    题目链接 题意:要在m个数里面选n个数, 要求这n个数的差值要最小 题意在hint里很清晰了 这道题从题意到题目本身都没有什么trick 写这道题完全是为了用一下#include <numeri ...

  3. C#中使用正则表达式提取超链接地址的集中方法(转)

    一般在做爬虫或者CMS的时候经常需要提取 href链接或者是src地址.此时可以使用正则表达式轻松完成. Regex reg = new Regex(@"(?is)<a[^>]* ...

  4. Android 完全退出程序,以及再按一次返回键退出程序

    再按一次返回键退出最终完整方案: boolean isExit; @Override    protected void onCreate(Bundle savedInstanceState) {   ...

  5. Standard Attachments in Oracle Form 标准附件

    Standard Attachments in Oracle Form 默认情况下"附件"按钮是灰色的,本文将展示如何让某个Form的附件按钮变亮,并能上传附件. 以用户Form为 ...

  6. 转:Apache和Nginx运行原理解析

    Web服务器 Web服务器也称为WWW(WORLD WIDE WEB)服务器,主要功能是提供网上信息浏览服务. 应用层使用HTTP协议. HTML文档格式. 浏览器统一资源定位器(URL). Web服 ...

  7. Microsoft Azure File 服务简介

    我们非常高兴地宣布在微软Azure中国区推出 Microsoft Azure File 服务预览版.Azure File 服务使用标准 SMB 2.1 协议提供文件共享.Azure 中运行的应用程序现 ...

  8. Xcode7工程改名

    0: 先把原工程压缩个zip包备份一份. 1:在Project navigator中, 选择旧工程名字, 再次点击, 修改. 会弹出提示框. 直接点击确认. (Xcode7.1.1中经常导致Xcode ...

  9. 热修复 RocooFix篇(一)

    吐槽之前先放一张大帅图. (md 这张图貌似有点小 不纠结这个了==) 有时候项目刚刚上线或者迭代 测试或者在线上使用测出一个bug来 真让人蛋疼 不得不重新改bug测试 打包混淆上线感觉就向find ...

  10. Get ListView items from other windows z

    This is more difficult than one might think. In order to get the information you're looking for, you ...