[英]Custom Navigation bar in iOS
Is it possible to add tow buttons under the navigation bar in iOS like shown in the image below: 是否可以在iOS的导航栏中添加拖曳按钮,如下图所示:
If yes, please tell me how it can be done. 如果是,请告诉我该怎么做。
查看Apple的Customizing UINavigationBar示例代码中的ExtendedNavBar示例。
Practically it's possible to do the same ;but i won't suggest you to do this,As this might break the app in upcoming release of iOS.. 实际上可行的是可以这样做;但是我不建议您这样做,因为这可能会在即将发布的iOS版本中破坏该应用程序。
If you want to do this then check the post here on Stackoverflow 如果要执行此操作,请在Stackoverflow上查看此处的帖子
iPhone - How set uinavigationbar height? iPhone-如何设置uinavigationbar的高度?
it will helps you making the navigation bar taller. 这将帮助您使导航栏更高。 Simply create a custom UINavigationBar subclass, which overrides sizeThatFits: and returns a large size.
只需创建一个自定义UINavigationBar子类,该子类将覆盖sizeThatFits:并返回较大的尺寸。
const CGFloat HeightToIncrease = 50.0f;
@implementation MyNavigationBar
- (CGSize)sizeThatFits:(CGSize)size {
CGSize amendedSize = [super sizeThatFits:size];
amendedSize.height += HeightToIncrease;
return amendedSize;
}
@end
You view will looks like the ![following][1] 您所看到的将看起来像![following] [1]
Now just override layoutSubviews in the navigation bar subclass and move the buttons and title up to make room for buttons 现在,只需覆盖导航栏子类中的layoutSubviews并向上移动按钮和标题即可为按钮留出空间
like following 喜欢以下
- (void)layoutSubviews {
[super layoutSubviews];
NSArray *classNamesToReposition = @[@"UINavigationItemView", @"UINavigationButton"];
for (UIView *view in [self subviews]) {
if ([classNamesToReposition containsObject:NSStringFromClass([view class])]) {
CGRect frame = [view frame];
frame.origin.y -= HeightToIncrease;
[view setFrame:frame];
}
}
}
this will make the room for the buttons you want to place in the navigation . 这将为您要在导航中放置按钮的空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.