从 iOS 13 开始,Apple 提供了一堆字形,可以used https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/ “任何地方都可以使用图像”。
您可以使用 SF 符号来表示各种特定位置的任务和内容类型,例如导航栏、工具栏、选项卡栏、上下文菜单和主屏幕快速操作。在应用程序的其余部分中,您可以在任何可以使用图像的地方使用符号。
因此,我希望这段代码将字形设置为UIBarButtonItem
的图像:
shareButton = UIBarButtonItem(
image: UIImage(named: "square.and.arrow.up"), // the name for the 'action' (Share) glyph
style: .plain,
target: self,
action: #selector(mySelector))
但由于找不到图像,应用程序崩溃了。
我尝试附加.png
图像名称,但这没有什么区别。
我们如何以编程方式设置 iOS 13 字形?
- 注意:我安装了 SF Symbols 应用程序并成功将字形设置为 UIBarButtonItems 的图像在故事板中.
Replace:
UIImage(named: "square.and.arrow.up")
With:
UIImage(systemName: "square.and.arrow.up")
这现在记录在UIImage https://developer.apple.com/documentation/uikit/uiimage/configuring_and_displaying_symbol_images_in_your_ui
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)