Created
August 6, 2022 13:09
-
-
Save 1998code/134586a51071e8e370d8a36660bcb753 to your computer and use it in GitHub Desktop.
Pick an app icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@AppStorage("appIcon") private var appIcon: String = "" | |
@State var appIcons = ["AppIcon", "AppIcon 2"] | |
var body: some View { | |
Picker(selection: $appIcon, label: Text("App Icon Picker")) { | |
ForEach(appIcons, id: \.self) { icon in | |
Text(icon).tag(icon) | |
} | |
}.pickerStyle(.wheel) | |
.onChange(of: appIcon) { newIcon in | |
UIApplication.shared.setAlternateIconName(newIcon == "AppIcon" ? nil : newIcon) | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment