Rob N Rob N - 25 days ago 8
iOS Question

Get the image for UITableViewCell detail accessory view

This image shows up in

UITableViewCell
accessories.

enter image description here

Is there a way to get it from the system, when you're not using a table view, to use in a bare
UIImageView
? Obviously I can screenshot it, but I want to be consistent with whatever iOS is using for the icon.

Answer Source

Sure, if you want a button with this icon, you can do it programmatically or using Storyboards.

Using Storyboards:

Just create a button and with your button selected open up the Attributes Inspector, and under Type just select whatever type you need. In your case, it's going to be "Info Light":

enter image description here

Programmatically:

You can initialize your button using its type:

let button = UIButton(type: .infoLight)

button.addTarget(self, action: #selector(someCoolStuff), for: .touchUpInside)

// ...

And in both cases your button would end up looking like this:

enter image description here

Note: Please note however that you cannot do this while using an image view because it's not what it is made for.