【发布时间】:2018-12-16 18:15:00
【问题描述】:
我有一个 swift 4 / iOS 12 应用程序,它为所有视图控制器使用自定义导航栏 barTintColor,并在 appDelegate.swift 中设置如下:
UINavigationBar.appearance().barTintColor = UIColor(red: 229/255, green: 80/255, blue: 57/255, alpha: 1.0)
但是,当我呈现一个activityViewController 时,我想更改颜色,以便邮件撰写视图获得一个白色的barTint。我通过这样做实现了这一点:
let activityViewController = UIActivityViewController(activityItems: textShare , applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: { () in
UINavigationBar.appearance().barTintColor = UIColor.white
})
但是当我关闭 activityViewController 时,导航栏的 tintColor 已针对整个应用程序发生了变化。这不是我想要的行为。我希望在关闭 activityViewController 时将 tintColor 设置回来,但我不知道如何捕捉“willDisappear”函数以便将其设置回来。
【问题讨论】:
标签: swift uiactivityviewcontroller bartintcolor