I'm not talking about custom images that one can upload to the Xcode project, I mean the free images that Apple provides through Xcode. Things like sun and star icons. How can someone access these in code? This is what I have so far below (simplified example):
@IBOutlet weak var favoriteSymbol: UIImageView!
override func viewDidLoad() {
favoriteSymbol.image = // How to access Apple icon here, like "star.filled"?
}
Do I need to download the image and then add it to the Assets folder, or are they built in? In case it matters, I'm using storyboards. There is an image already placed on the storyboard, which I will change to the "star.filled" icon programatically.
CodePudding user response:
To use an SF Symbol, use systemName
:
let image = UIImage(systemName: "square.and.pencil")
Note: The specified icon MUST exist within the SF Symbols library. However, you can make custom SF Symbols as explained