spicyshrimp / ios-11-uinavigationitem-sxfixspace Goto Github PK
View Code? Open in Web Editor NEWiOS11导航栏按钮的位置偏移问题的解决方案 及iOS11之前的导航栏按钮的位置偏移问题的解决方案
License: MIT License
iOS11导航栏按钮的位置偏移问题的解决方案 及iOS11之前的导航栏按钮的位置偏移问题的解决方案
License: MIT License
再push一个viewcontronller。回来的时候。 靠左边的约束直接没有了。返回按钮直接靠到屏幕去了,没有间距。 如果不push,用起来是正常的。 有联系方式么?
leftBarButtonItem的左边、rightBarButtonItem的右边16像素点击无响应
把左右barbutton的约束移除后,中间的titleview的约束不对了,导致显示不出来或者撑开到整个屏幕的宽度
左边的会右移,右边的会左移,有时候右边的还会消失
好像不是太好用
只是修改了偏移位置,点击区域并不能兼容
不设置偏移位置,效果好像并没有什么用,还是距离边距很远
如何同时放两个按钮呢?
UIBarButtonItem *item1 = [UIBarButtonItem itemWithTarget:self action:@selector(pushAction) image:[UIImage imageNamed:@"nav_add"]]; UIBarButtonItem *item2 = [UIBarButtonItem itemWithTarget:self action:@selector(pushAction) image:[UIImage imageNamed:@"nav_add"]]; self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:item1,item2,nil];
是不行的
貌似直接在这个方法这样写也不对
`+(UIBarButtonItem *)itemWithTarget:(id)target
action:(SEL)action
nomalImage:(UIImage *)nomalImage
higeLightedImage:(UIImage *)higeLightedImage
imageEdgeInsets:(UIEdgeInsets)imageEdgeInsets {
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
[button setImage:[nomalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
if (higeLightedImage) {
[button setImage:higeLightedImage forState:UIControlStateHighlighted];
}
[button sizeToFit];
if (button.bounds.size.width < 40) {
CGFloat width = 40 / button.bounds.size.height * button.bounds.size.width;
button.bounds = CGRectMake(0, 0, width, 40);
}
button.imageEdgeInsets = imageEdgeInsets;
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
[button1 addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
[button1 setImage:[nomalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
if (higeLightedImage) {
[button1 setImage:higeLightedImage forState:UIControlStateHighlighted];
}
[button1 sizeToFit];
if (button1.bounds.size.width < 40) {
CGFloat width = 40 / button1.bounds.size.height * button1.bounds.size.width;
button1.bounds = CGRectMake(45, 0, width, 40);
}
button1.imageEdgeInsets = imageEdgeInsets;
UIView *viewBtn = [[UIView alloc]initWithFrame:CGRectMake(0, 0, (button.frame.size.width + button1.frame.size.width +5), 40)];
[viewBtn sizeToFit];
[viewBtn addSubview:button];
[viewBtn setUserInteractionEnabled:YES];
[viewBtn addSubview:button1];
// viewBtn.backgroundColor = [UIColor yellowColor];
return [[UIBarButtonItem alloc] initWithCustomView:viewBtn];
}`
在执行的时候没法找到 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIBarButtonItem itemWithTarget:action:image:]: unrecognized selector sent to class 0x104e51c20'
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.