HomeiOS DevelopmentCustomized ControlWidgetButton SFSymbol Icon on iOS 26

Customized ControlWidgetButton SFSymbol Icon on iOS 26


I am attempting to implement a ControlWidgetButton on iOS 26, and can’t appear to have a customized image seem.

As a easy take a look at in SFSymbols, I first duplicated the viewfinder icon as a customized image named customized.viewfinder and exported it utilizing the Export Image… menu possibility.

I then created a brand new Picture Image Set in Xcode and dragged within the exported image to import it into Xcode.

I attempted two totally different strategies for displaying an icon within the management.

  1. Picture(systemName: "customized.viewfinder")
  2. Picture("customized.viewfinder")

I additionally tried the inbuilt SF image strategy

  1. Picture(systemName: "viewfinder")

The outcomes of those three exams may be seen right here:
Customized ControlWidgetButton SFSymbol Icon on iOS 26

Solely the inbuilt system symbols appear to look. I can’t get my customized image to be displayed within the management, although it does show in my important SwiftUI app when importing the identical customized asset file.

Here is a snippet of the code I’m utilizing the show the icons.

struct LaunchScanControl: ControlWidget {
    static let variety: String = "com.instance.web site.management"

    var physique: some ControlWidgetConfiguration {
        StaticControlConfiguration(
            variety: Self.variety,
        ) {
            ControlWidgetButton("Scan", motion: LaunchScanIntent()) {_ in
                Label {
                    Textual content("Scan")
                } icon: {
                    Picture(systemName: "customized.viewfinder")
                }

            }
        }
        .displayName("Title")
        .description("Seize a product.")
    }
}

Has anybody had success with including a customized icon to their management, particularly with iOS 26? What strategy labored for you?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments