How to use default iOS images?
Asked Answered
U

6

59

I know how to use images in iOS application. But I don't know how to use default images like share or bookmark icons which are mention in developer site.

I want to use them. Do I need to download those set of images or those are available in Xcode?

If we have to download them, where I can get those icons?

Unwelcome answered 1/5, 2014 at 14:21 Comment(4)
Could you provide link to page where images that you asking are displayed?Sherr
Or it even better if you attach it the question.Sherr
developer.apple.com/library/ios/documentation/userexperience/…Unwelcome
https://mcmap.net/q/330916/-how-to-set-ios-13-glyphs-programmatically-duplicateHalfmast
S
16

Developers haven't direct access to these images. I mean that you can't initialise image object like this:

UIImage *image = [UIImage imageNamed:@"name_of_system_image"];

But you can display some of images by using system types. For example you could init UIBarButtonItem with system types that provides standard icons:
- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action

Where UIBarButtonSystemItem provides such types:

UIBarButtonSystemItemDone, UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo,
UIBarButtonSystemItemRedo,
UIBarButtonSystemItemPageCurl

Sherr answered 1/5, 2014 at 14:41 Comment(3)
Unfortunately in this case you cannot modify title and stuck with iOS default title for those images, correct?Morville
Yes, @YuriS, you cannot change the title on the system items. This is because they are automatically "localized" for you: they will display in whatever language the user has set on their device. If you want to use your own text for the title, and you wanted to display the text in different languages, you would have to provide your own translations for your text.Elam
You follow - developer.apple.com/documentation/uikit/…Indra
H
104

Now starting from Swift 5.1 and Xcode 11 you can load 1 from over 1500 system images with the new UIImage Api UIImage(systemName: "imageName") which are vector based so no worries about qualities for different sizes

https://developer.apple.com/design/resources/

enter image description here

Henrieta answered 4/6, 2019 at 8:22 Comment(3)
Thanks, for system images is systemName:String and for my assets images is name:StringDisingenuous
But only wtih iOS 13.0 and greater. Any idea how to use it for iOS 11 or 12?Spaniard
@Shree Ranga Raju Did you find out the answer?Syrupy
P
20

Swift 5.1, Xcode 11

Here is one example of SF Symbols..About 1500 system images are provided by apple with different weights and scales.

let homeSymbolConfiguration = UIImage.SymbolConfiguration(pointSize: 55, weight: .black)
let homeImage = UIImage(systemName: "house", withConfiguration: homeSymbolConfiguration)
let width = homeImage?.size.width
let height = homeImage?.size.height
let homeButton = UIButton(frame: CGRect(x: 100, y: 100, width: width!, height: height!))
homeButton.tintColor = UIColor.gray
homeButton.setImage(homeImage, for: .normal)
view.addSubview(homeButton)

Apple has provided a Mac app SF Symbols with all the system images. They all are in svg format means they are scalable. You can export and edit them.

Follow this WWDC 2019 Session 206. https://developer.apple.com/videos/play/wwdc2019/206/

Pugh answered 14/6, 2019 at 12:2 Comment(2)
Requires iOS 13 or above.Troublemaker
Unfortunately, you can’t use SF Symbols directly on iOS 12 and below as you can on iOS 13 and up. If you’d like to use any of the symbols on iOS 12 and below you need to export them from the SF Symbols Mac app and import them as regular assets in your Asset Catalog.Torbert
S
16

Developers haven't direct access to these images. I mean that you can't initialise image object like this:

UIImage *image = [UIImage imageNamed:@"name_of_system_image"];

But you can display some of images by using system types. For example you could init UIBarButtonItem with system types that provides standard icons:
- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action

Where UIBarButtonSystemItem provides such types:

UIBarButtonSystemItemDone, UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo,
UIBarButtonSystemItemRedo,
UIBarButtonSystemItemPageCurl

Sherr answered 1/5, 2014 at 14:41 Comment(3)
Unfortunately in this case you cannot modify title and stuck with iOS default title for those images, correct?Morville
Yes, @YuriS, you cannot change the title on the system items. This is because they are automatically "localized" for you: they will display in whatever language the user has set on their device. If you want to use your own text for the title, and you wanted to display the text in different languages, you would have to provide your own translations for your text.Elam
You follow - developer.apple.com/documentation/uikit/…Indra
N
6

In swift : For System images , Simply do it

imageView?.image = UIImage(systemName: "face.smiling")

happy coding :) Hit Upvote

System Resources are here: https://developer.apple.com/design/resources/

Neely answered 8/4, 2021 at 5:14 Comment(0)
M
0

For older iOS versions:

 if #available(iOS 13.0, *) {
            cell.buttonImageIcon.image = UIImage(systemName: "info.circle.fill")
            cell.profileButton.tintColor = UIColor.white
            cell.profileButton.setTitle("PERSONAL INFORMATION", for: .normal)
        } else {
            // Fallback on earlier versions
        }
Myriagram answered 9/12, 2021 at 10:56 Comment(2)
What is the fallback version?Syrupy
Does not add anything to the answers from 2019. Would be improved with a link to happycoding.app/index.html or some actual fallbackTravax
N
0

How to use System Name Image (SF Symbols) ?

 lazy var scanImg: UIImageView = {
        let img = UIImageView()
        img.image = UIImage(systemName: "sensor.tag.radiowaves.forward")
        img.tintColor = .systemBlue
        img.contentMode = .scaleAspectFit
        return img
    }()
    
Neonate answered 22/2 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.