自定义 UINavigationBar
我想要一个自定义的导航栏。但是导航栏和状态栏之间有一个空白。代码如下:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
谢谢您的帮助!
I want have a custom navigationbar .But there is a white space between navigationbar and status bar.The code is below:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要覆盖类别中的方法。
不要覆盖类别中的方法。
不要覆盖类别中的方法。
现在那已经不成问题了。
这仅意味着您的图像中有白线,或者您的导航栏放置不正确。
Do not override methods in categories.
Do NOT override metods in categories.
DO NOT OVERRIDE METHODS IN CATEGORIES.
Now that that is out of the way.
This just means that your image has the white line in it, or your navigation bar is placed incorrectly.
问题不一定出在导航栏中。导航控制器或视图控制器的框架可能未正确设置。
导航控制器或视图控制器有可能为
状态栏
或导航栏
留下空间,而不知道它们是否已经存在。确保您使用正确的
框架
创建导航控制器或视图控制器。The problem may not be necessarily in navigation bar. The frame of the navigation controller or view controller may not have been set properly.
There are chances that the navigation controller or view controller leaves space for
status bar
ornavigation bar
without having any idea about whether they are already there or not.Make sure you are creating the navigation controller or view controller with proper
frames
.