Skip to content

Instantly share code, notes, and snippets.

@katzenbaer
Last active June 9, 2021 00:03
Show Gist options
  • Save katzenbaer/9929a61f652ebf63d115f931da7cb48f to your computer and use it in GitHub Desktop.
Save katzenbaer/9929a61f652ebf63d115f931da7cb48f to your computer and use it in GitHub Desktop.
//
// AlternateAppIcon13SampleApp.swift
// AlternateAppIcon13Sample
//
// Created by Terrence Katzenbaer on 6/8/21.
//
import SwiftUI
@main
struct AlternateAppIcon13SampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
let iconName: String = "RelationshipIcon"
var body: some View {
Button(action: {
if UIApplication.shared.alternateIconName == iconName {
UIApplication.shared.setAlternateIconName(nil) { (error) in
// FIXME: Handle error
}
} else {
UIApplication.shared.setAlternateIconName(iconName) { (error) in
// FIXME: Handle error
}
}
}, label: {
Text("Swap icon!")
})
}
}
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