File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // UIApplication.swift
3+ // StoreKitHelper
4+ //
5+ // Created by wong on 12/31/25.
6+ //
7+
8+ #if canImport(UIKit)
9+ import UIKit
10+
11+ extension UIApplication {
12+ static func applicationIconImage( ) -> UIImage ? {
13+ guard
14+ let icons = Bundle . main. infoDictionary ? [ " CFBundleIcons " ] as? [ String : Any ] ,
15+ let primary = icons [ " CFBundlePrimaryIcon " ] as? [ String : Any ] ,
16+ let iconFiles = primary [ " CFBundleIconFiles " ] as? [ String ] ,
17+ let iconName = iconFiles. last
18+ else {
19+ return nil
20+ }
21+ return UIImage ( named: iconName)
22+ }
23+ }
24+ #endif
Original file line number Diff line number Diff line change @@ -194,8 +194,9 @@ private struct HeaderView: View {
194194 Image ( nsImage: NSImage ( named: NSImage . applicationIconName) !)
195195 . resizable ( )
196196 . frame ( width: 28 , height: 28 )
197- #else
198- if let appIcon = Bundle . main. icon {
197+ #endif
198+ #if canImport(UIKit)
199+ if let appIcon = UIApplication . applicationIconImage ( ) {
199200 Image ( uiImage: appIcon)
200201 . resizable ( )
201202 . scaledToFit ( ) // 适应图标的比例
Original file line number Diff line number Diff line change @@ -201,8 +201,9 @@ private struct HeaderView: View {
201201 Image ( nsImage: NSImage ( named: NSImage . applicationIconName) !)
202202 . resizable ( )
203203 . frame ( width: 76 , height: 76 )
204- #else
205- if let appIcon = Bundle . main. icon {
204+ #endif
205+ #if canImport(UIKit)
206+ if let appIcon = UIApplication . applicationIconImage ( ) {
206207 Image ( uiImage: appIcon)
207208 . resizable ( )
208209 . scaledToFit ( ) // 适应图标的比例
You can’t perform that action at this time.
0 commit comments