我想在FontAwesome Swift库中使用一些图标作为UITabBarItem的图片。 我已经可以设置UITabBarItem的标题,但是我无法设置UITabBarItem的图片。我的代码如下:
编译器告诉我“String”不能转换为“UIImage”。有没有办法将字符串转换为UIImage,或者有其他解决方法吗?
提前感谢。
class AEVTabBarController: UITabBarController {
var itemLabels = ["Promos", "Marcas", "Amigos", "Cerca de mí", "Más"]
override func viewDidLoad() {
super.viewDidLoad()
let tabItems = self.tabBar.items as [UITabBarItem]!
for index in 0..<itemLabels.count {
let currentItem = tabItems[index] as UITabBarItem
currentItem.title = itemLabels[index]
currentItem.image = String.fontAwesomeIconWithName(FontAwesome.Money) as UIImage
}
}
}
编译器告诉我“String”不能转换为“UIImage”。有没有办法将字符串转换为UIImage,或者有其他解决方法吗?
提前感谢。