从iOS 13开始,Apple提供了一堆标志符号,它们可以是used “您可以在任何地方使用图像的地方”。
您可以使用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))
但是由于找不到图片,应用崩溃了,显示为nil。
我尝试将.png
附加到图像名称上,但是没有区别。
答案 0 :(得分:0)
替换:
UIImage(named: "square.and.arrow.up")
使用:
UIImage(systemName: "square.and.arrow.up")
现在记录在UIImage
中