-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathIconView.swift
37 lines (31 loc) · 911 Bytes
/
IconView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// ContentView.swift
// icon
//
// Created by Ganesh on 25/08/23.
//
import SwiftUI
struct IconView: View {
let appIcons:[String] = ["AppIcon 1","AppIcon 2"]
var body: some View {
List{
ForEach(appIcons,id: \.self) { name in
Button {
UIApplication.shared.setAlternateIconName(name)
} label: {
Text(name)
.fontWeight(.bold)
}
}
}
}
}
extension Bundle{
public var icon: UIImage?{
guard let icons = infoDictionary?["CFBundleIcons"] as? [String: Any],
let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any],
let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String],
let iconFileName = iconFiles.last else {return nil}
return UIImage(named: iconFileName)
}
}