gpt4 book ai didi

iphone - 导航栏图片隐藏自定义导航栏按钮

转载 作者:行者123 更新时间:2023-11-29 11:14:30 25 4
gpt4 key购买 nike

我可以为导航栏提供图像,也可以更改导航栏按钮项目的图像。出于某种原因,我猜导航栏图像重叠在导航栏按钮图像上。当我单击左侧的导航栏图像但导航栏按钮未显示在导航栏图像上时,导航栏按钮正常工作。这是代码;

UIImage *imagebar = [UIImage imageNamed: @"schedule-strip.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: imagebar];
imageView.frame = CGRectMake(0, 0, 190, 44);
imageView.contentMode = UIViewContentModeScaleAspectFill;
self.navigationItem.titleView = imageView;


UIImage* image = [UIImage imageNamed:@"back-icon.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* someButton = [[UIButton alloc] initWithFrame:frame];
[someButton setBackgroundImage:image forState:UIControlStateNormal];
[someButton setShowsTouchWhenHighlighted:YES];
[someButton addTarget:self action:@selector(backToMore) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* someBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:someButton];
[self.navigationItem setLeftBarButtonItem:someBarButtonItem];

[someBarButtonItem release];
[someButton release];

帮帮我。

最佳答案

使用代码[imageView addsubView someButton];

我希望现在您会看到该按钮。实际上,您正在将左栏按钮项目添加到默认导航栏,并且当您创建某个按钮时,它不会添加到与您的导航栏重叠的 imageview 上。因此,通过单击该区域它正在工作,但按钮不可见。

关于iphone - 导航栏图片隐藏自定义导航栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10070893/

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