AlternativeAppIcons
Let users choose app icons with SwiftUI on iOS 16
Preview
Environment
- iOS 16
- Xcode 14 beta 4 or above
Tutorial
Medium (https://bit.ly/3A3M5Bs)
Demo
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()
}
}
License
MIT