如何删除自定义导航栏图像?
我使用下面的代码来设置导航栏的背景。它有效,但由于我不希望它出现在所有导航栏上,因此我必须在离开当前视图之前将其删除。怎么办呢?
- (void)viewDidLoad
{
UIImageView *nav_img = [[UIImageViw alloc] initWithImage:[UIImage imageNamed:@"header-background.png"]];
nav_img.frame = CGRectMake(0.0,0.0,320.0,44.0);
[self.navigationController.navigationBar insertSubView:nav_img atIndex:0];
[nav_img release];
}
感谢您的帮助,
斯蒂芬
I'm using the code below to set a background to a navigation bar. It worked but as I don't want it on all navigation bars, I have to remove it before leaving the current view. How to do it ?
- (void)viewDidLoad
{
UIImageView *nav_img = [[UIImageViw alloc] initWithImage:[UIImage imageNamed:@"header-background.png"]];
nav_img.frame = CGRectMake(0.0,0.0,320.0,44.0);
[self.navigationController.navigationBar insertSubView:nav_img atIndex:0];
[nav_img release];
}
Thx for helping,
Stephane
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加标签时,将标签添加到图像视图。使用
viewWithTag:
方法获取指向图像视图的指针,并在viewWillAppear
和中设置图像视图的
方法。hidden
属性viewWillDisappearAdd a tag to the image view as you add it. Use the
viewWithTag:
method to get a pointer to the image view and set thehidden
property of the image view in yourviewWillAppear
andviewWillDisappear
methods.