ioscolorsuikitsf-symbols

How to change SF Symbol icon color in UIKit?


In SwiftUI, you can change the icon's color using foregroundColor modifier:
Change the stroke/fill color of SF Symbol icon in SwiftUI?

Is there a way to change the color in UIKit? I looked up the documentation and didn't find anything related to it.

let configuration = UIImage.SymbolConfiguration(pointSize: 16, weight: .regular, scale: .medium)
let iconImage = UIImage(systemName: "chevron.right", withConfiguration: configuration)

Solution

  • Use:

    let icon = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))
    icon.tintColor = .red