问题描述
首先,感谢您来到这里并帮助解决我的问题。谢谢!!!
First of all, thank you for coming here and help solving my problem. Thank you!!!
在iOS11 beta6中, sizeThatFits:
似乎无法在UINavigationBar上运行。我注意到通过显示我的应用程序改变了UINavigationBar结构。
In iOS11 beta6, sizeThatFits:
seems to not work on UINavigationBar. I notice that UINavigationBar structure has changed by Reveal my app.
我已经尽力改变自定义导航栏的高度。但似乎总是 44
,它在iOS11之前有效。
I have tried my best to change custom navigation bar's height. But it seems always to be 44
, and it works before iOS11.
- (CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(self.frame.size.width, 64);
return newSize;
}
奇怪的是,我只是在中记录了它的框架didMoveToSuperview
方法,它的高度是64,但我真的看到在Reveal和app中是44。
Oddly, I just log its frame in didMoveToSuperview
method, its height is 64, but I really see that is 44 in Reveal and app.
我对此一无所知...请帮帮我..谢谢你。
I have no idea about this... Help me please.. Thank you.
我发现关于我的自定义导航栏LayoutConstraints登录控制台如下:
I found that about my custom navigation bar LayoutConstraints log in console like this :
"<NSAutoresizingMaskLayoutConstraint:0x604000495ae0 FDCustomNavigationBar:0x7fe2f01399d0.(null) == 42>",
"<NSAutoresizingMaskLayoutConstraint:0x604000495b30 FDCustomNavigationBar:0x7fe2f01399d0.height == 44>"`
bug我甚至没有使用自动布局我的导航栏。这有什么问题?
bug I even no use auto layout in my navigation bar. What's wrong with it?
我在导航栏的<$ c设置了我的自定义导航栏的子视图框架$ c> -
layoutSubviews 方法。
- (void)layoutSubviews {
[super layoutSubviews];
self.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), 64);
for (UIView *view in self.subviews) {
if([NSStringFromClass([view class]) containsString:@"Background"]) {
view.frame = self.bounds;
} else if ([NSStringFromClass([view class]) containsString:@"ContentView"]) {
CGRect frame = view.frame;
frame.origin.y = 20;
frame.size.height = self.bounds.size.height - frame.origin.y;
view.frame = frame;
}
}
}
但导航栏将覆盖查看控制器的视图。我该如何解决这个问题?
but the navigation bar will cover view controller's view. How can I fix that?
推荐答案
由于iOS 11 UINavigationBar完全支持自动布局(这就是你看到它的原因约束)。我已经向Apple打开了雷达,因为我认为为titleView设置高度约束会相应地调整导航栏高度。然而,这就是Apple回复的内容:
Since iOS 11 UINavigationBar fully supports Auto Layout (this is the reason why you're seeing its constraints). I've opened a radar to Apple because I thought that setting a height constraint to the titleView would have adjusted the navigation bar height accordingly. However this is what Apple replied:
截至今天,雷达仍处于打开状态。
As of today the radar is still open.
这篇关于iOS11自定义导航栏高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!