[英]Adding an image to a tab bar item only shows up as a block
I have a tab bar which should have an image for the selected index. 我有一个选项卡栏,其中应该包含所选索引的图像。
Below is a sample-image which sould be used inside my tab bar. 下面是一个示例图像,可以在我的标签栏中使用。
I have added it by selecting the connected view controller assigned to the tab bar item and replacing the image. 通过选择分配给选项卡栏项目的已连接视图控制器并替换图像来添加它。 However this is what actually appears on the screen.
但这实际上是屏幕上显示的内容。 The assigned graphics is not appearing on the tab bar.
分配的图形未显示在选项卡栏上。
You can add this line self.tabBarItem.image = UIImage(named: "icono-menu")?.withRenderingMode(.alwaysOriginal)
in your item viewController
viewDidLoad 您可以在项目
viewController
viewDidLoad中添加以下这一行self.tabBarItem.image = UIImage(named: "icono-menu")?.withRenderingMode(.alwaysOriginal)
something like this 像这样的东西
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tabBarItem.image = UIImage(named: "icono-menu")?.withRenderingMode(.alwaysOriginal)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.