简体   繁体   中英

Adapt SF symbols to iOS version

I'm currently developing an iOS app that has iOS 13 set as deployment target. I'm using some SF symbols throughout the app. Now, since iOS 14 and a new version of XCode have been available, I've been getting a warning about one of my symbols being deprecated ( paragraphsign should be used instead of paragraph ), however, when I change the image to paragraphsign in Interface Builder, I'm getting an error saying that this symbol is only available in iOS 14...

Now, my current solution is to ignore the warning and instead use

if #available(iOS 14, *)
{
    ...
}

in my code to replace all deprecated images with their new versions.

My question is: Is there a way to do this in Interface Builder directly to avoid the warning? Something like "use this in iOS 14 and that in prior versions"?

One option, if you don't want to just ignore the warning...

Using the SF Symbols app, select the "paragraphsign" and:

File -> Export Custom Symbol Template

Save it as paragraphsign.svg and then drag it into your asset catalog. That image will be used when running on iOS 13... the actual paragraphsign SF Symbol will be used when running on iOS 14.

No code needed.

Exporting from SF Symbols and then using this svg in asset catalog is working only if you use a name for Symbol image without dots ("."). For example: Symbol image name "speaker.wave.1.fill" won't work. Warning will disappear, but symbol will not show on WatchOS 6. When I renamed same Symbol Image to "Speaker1fill" and use this image instead of system image, it worked for all WatchOS versions.

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