我已經寫在迅速的iOS應用覆蓋缺省導航欄背景AppDelegate
:UINavigationBar的外觀UIDocumentInteractionController
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let navBackgroundImage = UIImage(named: "navBck")
UINavigationBar.appearance().barTintColor = UIColor(patternImage: navBackgroundImage)
}
在我想用一個UIDocumentInteractionController
來顯示PDF文件的應用生成的應用程序。
let docInteractionController = UIDocumentInteractionController(url: pdfURL!)
docInteractionController.delegate = self
docInteractionController.presentPreview(animated: true)
的問題是,自定義背景我似乎並不支持,這與以下錯誤崩潰
斷言失敗(這並不沒有AppDelegate
自定義背景發生) - [ UICGColor encodeWithCoder:],/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.7.47/UIColor.m:1549 由於未捕獲的異常「NSInternalInconsistencyException」而終止應用程序,原因:'僅限RGBA或在這種情況下,支持白色色彩空間。'
我正在尋找最簡單最簡單的方法來解決此問題,方法是將ARGB背景恢復爲僅用於此操作的導航欄。我試圖在我的UIDocumentInteractionControllerDelegate
執行下面沒有運氣(有相同的錯誤崩潰)
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
UINavigationBar.appearance().barTintColor = UIColor.darkGrey
return self
}
func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController)
{
let navBackgroundImage:UIImage! = UIImage(named: "navBck")
UINavigationBar.appearance().barTintColor = UIColor(patternImage: navBackgroundImage)
}
嘗試在呈現UIDocumentInteractionController之前設置barTintColor。 – tmrog
剛剛嘗試過,這給出了相同的錯誤 – tishu