spicyshrimp / uinavigation-sxfixspace Goto Github PK
View Code? Open in Web Editor NEW导航栏按钮位置偏移的解决方案,兼容iOS7~iOS15,可自定义间距
License: MIT License
导航栏按钮位置偏移的解决方案,兼容iOS7~iOS15,可自定义间距
License: MIT License
leftBarButtonItem 间距设置无效,right正常呀,又遇到吗?
UIBarButtonItem * backItem = [UIBarButtonItem itemWithTarget:nil action:nil image:[UIImage imageNamed:@"back_Image"]];
self.navigationItem.leftBarButtonItem = backItem;
这是创建按钮的代码 iOS11的位置正常, 11以下 我用iOS 9 的试了下 位置就不正常了
你把add那张图换成一张比较大的图,就变形了.宽度不能控制....写了没效果...
测试环境:模拟器
iOS10.3.1中,左边距离是4
iOS11.0,左边距离是8
https://blog.csdn.net/spicyShrimp/article/details/78201042
这篇博客中描述的方案是修改layoutMargins,但目前的实现又回到了修改约束吗?
页面跳转的时候,左右按钮会闪动
UINavigationSXFixSpace.m里面的sx_layoutSubviews方法,死循环调用了
0 CoreFoundation
-[NSInvocation invokeSuper] + 88
1 libobjc.A.dylib
objc_exception_throw + 60
2 CoreFoundation
-[__NSCFCalendar __findMatchingDate:afterStartDate:matchingComponents:goingBackwards:findLastMatch:options:] + 728
3 Foundation
-[NSProgress _notifyRemoteObserversOfValueForKeys:] + 248
4 UIKitCore
-[_UIStatusBarDisplayItemState updatePlacement] + 292
5 CoreFoundation
-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 648
6 UIKitCore
-[_UIStatusBar _updateRegionItems] + 80
7 UIKitCore
-[_UIStatusBar updateConstraints] + 68
8 UIKitCore
-[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 180
9 UIKitCore
-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 988
10 Foundation
-[NSLayoutAnchor nsli_lowerIntoExpression:withCoefficient:forConstraint:] + 912
11 UIKitCore
___100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke + 104
12 UIKitCore
-[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 128
13 UIKitCore
-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 184
14 UIKitCore
-[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 424
15 UIKitCore
-[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 344
16 HouseKeeper
-[NSObject(SXFixSpace) sx_layoutSubviews] (UINavigationSXFixSpace.m:156)
17 UIKitCore
-[_UIStatusBar layoutSubviews] + 56
18 UIKitCore
-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1308
19 libobjc.A.dylib
0x00000001c3bf6000 + 5204
右滑返回上一级好像无效?能打开吗
新版1.1.2的item距离两端的间距sx_defaultFixSpace设置任何值都无效,还是默认0的间距。用你的demo测试的也是这样。
项目中免不了需要用到第三方,用pod导入的,这样后面好维护项目
iOS11.2 popViewControllerAnimated:NO 时,UINavigationBar不调用layoutSubviews
设置了rightBarButtonItem 会和左边的返回按钮一样贴边,能独立配置下?不然每次去判断好麻烦。
在设置rightBarButtonItem为自定义View的时候,如果view内有用masonry写的布局的话,自定义view就会偏移或者大小改变!不知道是自动布局代码的问题还是哪里的问题。。。
真机 iPhone 6,10.3.3
RT,设置为13,左右各一个按钮,距离屏幕两边的间距变为了9,少了4px。系统为15.2,iphone x 系统15.1,无此问题,不像是15.0导致的,是否是iphone13的问题?
leftBarButtonItem 的距离左边的距离是消除掉了,但是leftBarButtonItem距离右边的边距变得很小了
感觉侵入性太大,会导致一些有导航栏的第三方库受到牵连,影响三方库的导航显示,能否加个hook黑名单功能,加入黑名单的类不受这个category的影响
iOS11系统此方法正常,iOS11系统以下:
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:15], NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
设置无效
self.navigationController.navigationBar.prefersLargeTitles = YES;
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAutomatic;
UINavigation-SXFixSpace-Swift这个库移除了吗?
-(void)sx_setRightBarButtonItems:(NSArray<UIBarButtonItem *> *)rightBarButtonItems{
if (rightBarButtonItems.count) {
NSMutableArray *items = [NSMutableArray arrayWithObject:[self fixedSpaceWithWidth:[UINavigationConfig shared].sx_defaultFixSpace-20]];//可修正iOS11之前的偏移
[items addObjectsFromArray:rightBarButtonItems];
[self sx_setRightBarButtonItems:items];
} else {
[self sx_setRightBarButtonItems:rightBarButtonItems];
}
}
如果外部直接调用,没有做系统版本的区分,会导边距调整失效。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.