简体   繁体   中英

how to programmatically, in Swift, set an uiimageview to the xcode built-in applewatch icon image?

I like the watch icon you get when you use storyboard to add a UIIMAGEVIEW and set its Image attribute to the built-in "applewatch" icon.

But when I programmatically create a UIIMAGEVIEW how can I set it to that cool icon?

Here I add a 3rd party.png of a wrist band. But I want to use the built-in which looks best:

let imageName = "Wrist Band.png"
let image = UIImage(named: imageName)
let imageView = UIImageView(image: image!)
imageView.frame = CGRect(x: 0, y: 0, width: 100, height: 200)
view.addSubview(imageView)

You seem to be talking about the SF symbol applewatch . You can get that (or any other SF symbol) by using UIImage(systemName:) :

UIImage(systemName: "applewatch")

Notes:

  • The color of the watch depends on the tintColor of the image view
  • Available on iOS 14+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM