是否可以将图像图标添加到特定视图中的导航栏?
是否可以将图像添加到导航栏?图像只能在特定视图中查看(即不能在整个应用程序中查看)...带有地球图标的示例:
https://i.sstatic.net/FsyH8.png
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
imgView.image = [UIImage imageNamed: @"1.bmp"];
[self.navigationController.navigationBar addSubview:imgView];
[self.navigationController.navigationBar bringSubviewToFront:imgView];
[imgView release];
Is it possible to add an image to the nav bar? The image should be viewed only in a certain view (i.e. not throughout the application)... Example with an earth icon:
https://i.sstatic.net/FsyH8.png
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
imgView.image = [UIImage imageNamed: @"1.bmp"];
[self.navigationController.navigationBar addSubview:imgView];
[self.navigationController.navigationBar bringSubviewToFront:imgView];
[imgView release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的!与将任何其他子视图添加到视图中的方式相同。
Yup! Same way you would add any other subView to a view.
如果您不想以编程方式执行此操作,也可以在界面生成器中添加图像。在界面生成器中选择一个按钮,并且在“栏项目”下的属性检查器中应该有一个选项可以使用该项目的图像
You can also add the image in interface builder if you don't want to do it programmatically. Select a button in interface builder and there should be an option to use an image for that item in the Attributes Inspector under "Bar Item"