iOS11导航栏自定义按钮偏移问题
来源:互联网 发布:中国知识分子知乎 编辑:程序博客网 时间:2024/05/24 03:08
iOS11之前小伙伴通过设置UIBarButtonSystemItemFixedSpace width=-10来解决按钮位置偏移问题,
UIButton *leftBtn = [[UIButtonalloc] initWithFrame:CGRectMake(0,0, 44,44)];
leftBtn.backgroundColor = [UIColorcyanColor];
[leftBtn setImage:[UIImageimageNamed:@"back.png"]forState:UIControlStateNormal];
[leftBtn addTarget:selfaction:@selector(back:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftItem = [[UIBarButtonItemalloc] initWithCustomView:leftBtn];
UIBarButtonItem *ItemSpace = [[UIBarButtonItemalloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
if (MODEL_VERSION >=7.0) {
ItemSpace.width = -10;
}
self.navigationItem.leftBarButtonItems =@[ItemSpace, leftItem];
如今iOS11上不可用了!!!
后来通过改变按钮的 contentEdgeInsets和imageEdgeInsets的值成功改变了按钮的偏移问题,单独设置contentEdgeInsets也可达到一定的效果。
UIButton *leftBtn = [[UIButtonalloc] initWithFrame:CGRectMake(0,0, 44,44)];
leftBtn.backgroundColor = [UIColorcyanColor];
leftBtn.contentEdgeInsets =UIEdgeInsetsMake(0, -20,0, 0);
leftBtn.imageEdgeInsets =UIEdgeInsetsMake(0, -15,0, 0);
[leftBtn setImage:[UIImageimageNamed:@"back"]forState:UIControlStateNormal];
[leftBtn addTarget:selfaction:@selector(back:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftItem = [[UIBarButtonItemalloc] initWithCustomView:leftBtn];
self.navigationItem.leftBarButtonItems =@[leftItem];
- iOS11导航栏自定义按钮偏移问题
- iOS11导航栏自定义按钮偏移问题
- iOS11 完美解决导航栏按钮偏移问题 韩俊强的博客
- iOS11NavigationItem偏移,iOS11适配问题,iOS11导航栏返回偏移,iOS11BarButtonItem偏移,Xcode9遇见的问题
- iOS 11 导航栏按钮偏移问题
- iOS11项目适配 UIScorllView下移和导航栏返回按钮偏移
- iOS11 导航栏按钮位置问题的解决
- iOS11 导航栏按钮位置问题的解决
- iOS11 导航栏按钮位置问题的解决------新
- 解决iOS导航栏左右按钮偏移问题
- 自定义返回按钮偏移问题
- ios11导航栏按钮不适配解决方法
- iOS11 UIScrollView 偏移量问题
- 导航栏自定义按钮
- 自定义导航栏按钮
- ios7以上,导航栏的按钮会出现向中间偏移问题的解决方法
- IOS 之iIOS11更新 导航返回按钮偏移的问题。。。。。
- IOS 11导航返回按钮偏移的问题
- 安卓手机文件管理的照片删了怎么找回的轻松恢复方法
- 因乐视网IPO财务造假,多位发审委委员被抓;旷视科技完成 4.6亿美元C轮融资丨价值早报
- Android自定义控件5----继承View通讯录索引功能之4在下按和移动时,列表更新
- sourceTree安装问题
- 马化腾:七大关键词打造“数字生态共同体”
- iOS11导航栏自定义按钮偏移问题
- Model 3产能再缩水,特斯拉遇“甜蜜的负担”
- CentOS7 安装 ActiveMQ
- Nginx的优化(突破十万并发)
- LuaSocket简单使用
- db2 57016问题
- Qt学习1-------ubuntu16.04下安装和helloworld
- Java 线程 5
- 数据库SQL优化大总结之 百万级数据库优化方案