iosswiftuiimageviewuiimagesf-symbols

iOS - Obtaining localised system image


I am referring to SF Symbols app for available system icons. If I have to use the asset, I could directly use the systemName to create UIImage. Recently I noticed that there is something called Localisation in SF Symbols app. But idea how could I convert this to code. For instance, if I have to use Right-to-Left localisation option of an asset in UIImage, how could this be done?

enter image description here


Solution

  • Just use the symbol as you normally would:

    let image = UIImage(systemName: "rectangle.portrait.and.arrow.forward")
    

    The actual direction of that symbol's arrow depends on the localizations your app supports and the user's chosen locale. If your app supports a right-to-left locale and the user has chosen that right-to-left locale then the arrow will point to the left.