![](/img/trans.png)
[英]How to increase height for a custom UINavigationBar class in Swift
[英]How to increase the height of UINavigationBar?
简单的问题:如何增加导航栏的高度,以便在保持模糊的同时使用其他小部件?
例如日历应用程序,其中工作日缩写添加到导航栏的底部...
...当您将邮件移动到另一个文件夹时,在Mail中:
由于iAnurag帖子ans是正确的但仍有一些ui问题(宽度不合适)
码
#import "ViewController.h" @implementation UINavigationBar (customNav) - (CGSize)sizeThatFits:(CGSize)size { CGRect rec = self.frame; CGRect screenRect = [[UIScreen mainScreen] bounds]; rec.size.width = screenRect.size.width; rec.size.height = 70; return rec.size; } @end
产量
When press on "Button"
https://developer.apple.com/library/prerelease/content/samplecode/NavBar/Introduction/Intro.html
来自ReadMe.md:
扩展导航栏####此示例演示如何以视图的方式在导航栏下方放置自定义视图似乎是导航栏本身的一部分。 此技术可用于创建类似于iOS日历应用程序的界面。
我不谦虚的意见:不要覆盖sizeThatFits(_:)
,不要在导航栏高度上设置约束。 从上面的例子中做出错觉。
使用自定义sizeThatFits创建UINavigationBar类别。
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize newSize = CGSizeMake(self.frame.size.width,70);
return newSize;
}
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.