先上代码

UIButton *settingBtn = [Utils creatCustomButtonWithFrame:CGRectMake(, , , ) btnTitle:@"设置" btnFontSize: titleColor:[UIColor blackColor]];
[settingBtn addTarget:self action:@selector(clickTheSettingBtn) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBar = [[UIBarButtonItem alloc]initWithCustomView:settingBtn];
self.navigationItem.rightBarButtonItem = rightBar;

效果为

若想调节该按钮位置,设置

settingBtn.titleLabel.textAlignment = NSTextAlignmentRight;

这样是没效果的。应利用UIBarButtonSystemItemFixedSpace格式,rightbar设为数组,进行填充。

UIButton *settingBtn = [SHUtils creatCustomButtonWithFrame:CGRectMake(, , , ) btnTitle:@"设置" btnFontSize: titleColor:[UIColor blackColor]];
[settingBtn addTarget:self action:@selector(clickTheSettingBtn) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBar = [[UIBarButtonItem alloc]initWithCustomView:settingBtn];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
negativeSpacer.width = -;
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer,rightBar,nil];

效果为

修改navigationbar右侧按钮离屏幕边缘位置的更多相关文章

  1. iOS 自定义NavigationBar右侧按钮rightBarButtonItem--button

    //两个按钮的父类view UIView *rightButtonView = [[UIView alloc] initWithFrame:CGRectMake(, , , )]; //历史浏览按钮 ...

  2. iOS 自定义NavigationBar右侧按钮rightBarButtonItem

    自定义右侧的一个按钮 UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"主页" style: ...

  3. 在使用element-ui搭建的表格中,实现点击"定位"按钮后,屏幕滚动到对应行的位置

    背景: 一个后台管理系统,当管理员登录之后,会存在一个自己的id值, 在一个表格中,当点击"定位"按钮后,屏幕滚动到拥有管理员id的这一行,并且给设置一个高亮的背景 相关知识点: ...

  4. [iOS微博项目 - 1.5] - NavigationBar标题按钮

    A.NavigationBar标题按钮 1.需求 在“首页”的导航栏中部设置一个“首页”文字+箭头按钮 统一设置样式 根据实际文本长度调整宽度 消除系统自带的点击高亮效果 点击按钮,箭头上下颠倒 gi ...

  5. 点击提交按钮,屏幕会出现闪烁问题,element.style问题

    点击提交按钮,屏幕会出现闪烁问题 通过后台调试发现,在点击的按钮的时候会给body添加一个padding值,而且会出现怎么都修改不了的问题,会发现里面会有 element.style的值,这其实是一种 ...

  6. Swift实现封装PopMenu菜单,可在屏幕任意位置弹出

    效果图: 说明: 代码现已支持 Swift3 语法 使用介绍: 1.初始化位置 //frame 为整个popview相对整个屏幕的位置 箭头距离右边位置,默认15 //popMenu = SwiftP ...

  7. IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容

    IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容 UIAlertController *alertVC = [UIAlertController alertControl ...

  8. WPF 获得鼠标相对于屏幕的位置,相对于控件的位置

    相对于屏幕的位置 第一步: /// <summary>    /// 用于获得鼠标相对于屏幕的位置    /// </summary>    public class Win3 ...

  9. iOS七大手势之(平移、捏合、轻扫、屏幕边缘轻扫)手势识别器方法

    使用手势很简单,分为两步: 创建手势实例.当创建手势时,指定一个回调方法,当手势开始,改变.或结束时,回调方法被调用. 添加到需要识别的View中.每个手势只对应一个View,当屏幕触摸在View的边 ...

随机推荐

  1. Android Programing 学习笔记(一)

    最近学习android 开发,拜读android programing,一步一步学习.囫囵吞枣,现已看到第十八章.今天把最近的学习过程中学到的一些内容进行一下总结. 一:Fragment 和 Acti ...

  2. Spring MVC小结

    Spring MVC项目搭建 添加依赖 (省略) Spring MVC配置类 @Configuration @EnableWebMvc @ComponentScan("com.sjx.spr ...

  3. Unity2D多分辨率屏幕适配方案(转载)

    一下内容转自:http://imgtec.eetrend.com/forum/3992 此文将阐述一种简单有效的Unity2D多分辨率屏幕适配方案,该方案适用于基于原生开发的Unity2D游戏,即没有 ...

  4. duplicate symbols for architecture armv7解决办法

    XCODE编译的时候报错:duplicate symbols for architecture armv7   1.首先排查是否有名字重复的文件:   2.检查是否在#import头文件的时候,不小心 ...

  5. 【解决】AgentSVN不能输入用户名/密码的问题

    在Microsoft SQL Server Management Studio中使用AgentSVN时,在完成如下图中配置时, 会提示认证失败错误.其原因是没有输入SVN用户和密码.但问题是此界面中没 ...

  6. 'libxml/tree.h' file not found

    看看Header Search Paths 为  '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Dev ...

  7. 16. Copy List with Random Pointer

    类同:剑指 Offer 题目汇总索引第26题 Copy List with Random Pointer A linked list is given such that each node cont ...

  8. loadrunner11遇到的问题汇总及相应的解决方案(持续更新)

    1.在此界面点击Run Load Tests提示: "Can not save the license information because access to the registry  ...

  9. Easyui CSS式样重写

    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui ...

  10. 去掉hive字段中的tab

    去除空格用trim 去除tab用如下方法 select regexp_replace(secdomainname,'\\s+','') from dwb_cndns_node_secdomain_d ...