gpt4 book ai didi

iphone - 无法在导航栏中设置完整图像

转载 作者:可可西里 更新时间:2023-11-01 05:58:55 24 4
gpt4 key购买 nike

我无法在导航栏(或应用程序顶部的导航 Controller )中设置完整图像。左边将剩下很少的空间。当我放置信息按钮时,它不在图像上。我该如何修复它

这是我的代码,请看一下

UIImageView* img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"headerBG.png"]];
img.frame = CGRectMake(0, 0, 320, 44);
self.navigationItem.titleView =img;
[img release];


UIButton * infoDarkButtonType = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
infoDarkButtonType.frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
infoDarkButtonType.backgroundColor = [UIColor clearColor];
[infoDarkButtonType addTarget:self action:@selector(showInfo) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] initWithCustomView:infoDarkButtonType];
self.navigationItem.leftBarButtonItem = infoButton;
[infoDarkButtonType release];
[infoButton release];

非常感谢。

我。

最佳答案

如果你想让导航栏显示图片,你试试这个

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect
{
UIImage *image = [UIImage imageNamed: @"custom_nav_bar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

关于iphone - 无法在导航栏中设置完整图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5945972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com