티스토리 뷰
iOS 10.3 부터 앱 아이콘 변경이 가능하다.
UIApplication에서 제공하는 setAlternateIconName 를 이용하면 된다.
@available(iOS 10.3, *) open func setAlternateIconName(_ alternateIconName: String?, completionHandler: ((Error?) -> Swift.Void)? = nil)
Assets를 이용해 보려고 했지만 제대로 동작이 되지 않아 png파일을 직접 추가해서 구현했다.
Info.plist에 아래 처럼 추가를 한다.
Source Code로 확인하면 아래와 같다.
<key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcons</key> <dict> <key>Icon1</key> <dict> <key>CFBundleIconFiles</key> <array> <string>icon1</string> </array> </dict> <key>Icon2</key> <dict> <key>CFBundleIconFiles</key> <array> <string>icon2</string> </array> </dict> <key>Icon3</key> <dict> <key>CFBundleIconFiles</key> <array> <string>icon3</string> </array> </dict> </dict> <key>CFBundlePrimaryIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string></string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>UINewsstandIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string></string> </array> <key>UINewsstandBindingEdge</key> <string>UINewsstandBindingEdgeLeft</string> <key>UINewsstandBindingType</key> <string>UINewsstandBindingTypeMagazine</string> </dict> </dict>
1. 앱 아이콘을 바꾸는 코드
UIApplication.shared.setAlternateIconName("Icon1") { (error) in if let error = error { print(error.localizedDescription) } }
2. 앱 아이콘을 초기화 하는 코드
UIApplication.shared.setAlternateIconName(nil) { (error) in if let error = error { print(error.localizedDescription) } }
변경시 아래와 같이 팝업이 뜬다.
참고 URL은 아래와 같다.
https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname
Souce Code
'iOS > UIApplication' 카테고리의 다른 글
iOS APNs 인증 키 p8 (iOS Key로 푸시 보내기) (2) | 2017.12.06 |
---|---|
iOS 최상위 뷰컨트롤러 확인하기 (presentedViewController) (0) | 2017.08.02 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- ios
- wkwebview
- swift
- 인증 키
- 앱 아이콘
- 리치 푸시
- UITextFieldDelegate
- shouldChangeCharactersIn
- appDelegate
- UIApplication
- Notification Service Extension
- Easy APNs Provider
- httpCookieStore
- swift3
- 이미지 푸시
- setAlternateIconName
- UITextFieldTextDidChange
- iOS Keys
- iOS10
- AppIcon
- UITextFiled
- UNUserNotificationCenterDelegate
- Create a New Key
- WebSiteDataStore
- UNUserNotificationCenter
- presentedViewController
- apns
- whose view is not in the window hierarchy
- NotificationCenter
- mutable-content
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함