From 511b08fe374a95ede2eb1e35d35a8d3365bbc181 Mon Sep 17 00:00:00 2001 From: iHTCboy Date: Mon, 3 Apr 2023 17:39:00 +0800 Subject: [PATCH] fix: App icon not showing --- .../icon/iAppStore_icon.imageset/Contents.json | 2 +- iAppStore/components/setting/AboutAppView.swift | 7 ++++++- iAppStore/components/setting/SettingHome.swift | 10 ++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/iAppStore/Assets.xcassets/icon/iAppStore_icon.imageset/Contents.json b/iAppStore/Assets.xcassets/icon/iAppStore_icon.imageset/Contents.json index 12cacf8..e78fa1a 100644 --- a/iAppStore/Assets.xcassets/icon/iAppStore_icon.imageset/Contents.json +++ b/iAppStore/Assets.xcassets/icon/iAppStore_icon.imageset/Contents.json @@ -1,11 +1,11 @@ { "images" : [ { + "filename" : "iAppStroe.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "iAppStroe.png", "idiom" : "universal", "scale" : "2x" }, diff --git a/iAppStore/components/setting/AboutAppView.swift b/iAppStore/components/setting/AboutAppView.swift index 52f25f0..0870c7f 100644 --- a/iAppStore/components/setting/AboutAppView.swift +++ b/iAppStore/components/setting/AboutAppView.swift @@ -16,7 +16,12 @@ struct AboutAppView: View { var body: some View { ScrollView { Spacer().frame(height: 50) - Image("iAppStore_icon").cornerRadius(15).padding(.bottom, 10) + Image("iAppStore_icon") + .resizable() + .frame(maxWidth: 90) + .frame(maxHeight: 90) + .cornerRadius(15) + .padding(.bottom, 10) Text("iAppStore").fontWeight(.bold).padding(.bottom, 5) Text("v \(appVersion ?? "") (\(appSubVersion ?? ""))").font(.footnote).foregroundColor(.gray).padding(.bottom, 10) Text("iAppStore 是一款使用 SwiftUI 打造的苹果商店工具类 App。").padding([.leading, .trailing], 20).padding(.bottom, 10) diff --git a/iAppStore/components/setting/SettingHome.swift b/iAppStore/components/setting/SettingHome.swift index a643a78..64b9112 100644 --- a/iAppStore/components/setting/SettingHome.swift +++ b/iAppStore/components/setting/SettingHome.swift @@ -64,7 +64,7 @@ struct SettingItemCell: View { var title: String var index: Int @State private var iconViewIsExpanded: Bool = false - @State private var icons: [String] = ["", "37", "37iOS", "37AppStore", "Apple", "AppleRainbow"] + @State private var icons: [String] = ["iAppStore", "37", "37iOS", "37AppStore", "Apple", "AppleRainbow"] var body: some View { @@ -74,15 +74,13 @@ struct SettingItemCell: View { let type = icons[index] VStack{ HStack { - Image(type.count > 0 ? type + "_icon" : "iAppStroe_icon") + Image(type + "_icon") .resizable() - .renderingMode(.original) .frame(width: 65, height: 65) .cornerRadius(15) - .padding(.bottom, 10) .padding(.leading, 5) - Text((type.count > 0 ? type : "默认") + "图标").padding(.leading, 15) + Text((index == 0 ? "默认" : type) + "图标").padding(.leading, 15) Spacer() @@ -91,7 +89,7 @@ struct SettingItemCell: View { } .onTapGesture { - UIApplication.shared.setAlternateIconName(type.count > 0 ? type : nil) + UIApplication.shared.setAlternateIconName(index == 0 ? nil : type) withAnimation{ iconViewIsExpanded = false