'Outer and inner stroke to SF Symbols image in iOS

Given an SF Symbol image in iOS, such as gear, I configure it with a custom color as follows:

    let settingsButtonConfig = UIImage.SymbolConfiguration(pointSize: 26, weight: .semibold, scale: .small)
    let settingsImage = UIImage(systemName: "gear", withConfiguration: settingsButtonConfig)

    
    settingsButton.setImage(settingsImage, for: .normal)
    settingsButton.tintColor = UIColor.gray

I also want to stroke the boundaries of this gear icon with black color so that it remains visible in all kinds of backgrounds (dark or light). Is there a way to achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source