如何使用其他系统图标?

How to use other system icons?

最近我想在我的 NavigationBar 中包含 iOS "star" 图标。但是当我查看 UIBarButtonItem.SystemItem 时,我注意到这些限制为 21 icons/images。 "star" 和许多 iOS 应用程序(甚至官方 Guideline Keynote)中使用的许多其他图标不包括在内。

有没有办法通过代码访问它们?

如果您想将其用作资产, 有许多图标网站提供免费和付费资产,例如 icons8

另一方面,如果您需要 Xcode 中的那些,唯一的方法就是将其用作 UITabBarItem。

那些来自 UITabBarItem init with TabBarSystemItem

简单示例

let favoritesItem = UITabBarItem.SystemItem.favorites
let bar = UITabBar(frame: CGRect(x: 20, y: 20, width: 100, height: 60))
let barItem = UITabBarItem(tabBarSystemItem: favoritesItem, tag: 0)
bar.items = [barItem]
view.addSubview(bar)

看多了可能你需要here

您也可以从 here 的 SDK 中提取 iOS SDK 图标,但我更喜欢下载它。