[英]Make UINavigationBar transparent animated during transition
我可以使用以下代碼做半透明的UINavigationBar透明:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
navigationController!.navigationBar.shadowImage = UIImage()
}
但是如果你試試這個,你會注意到推動動畫過渡期間的不良影響。 在左屏幕完全消失之前,導航欄立即變為透明。
但另一方面,如果你嘗試這個代碼....
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationController!.setNavigationBarHidden(true: animated: animated)
}
...動畫將是完美的:導航欄僅在右側屏幕上消失,因此過渡動畫看起來很好。
有沒有辦法讓UINavigationBar透明,就像在第一個片段中那樣具有動畫效果,就像在第二個片段中一樣?
是的,您需要在代碼中創建一個方法,這會延遲您的應用程序打開多少秒,例如:[self performSelector:@selector(delay)withObject:nil afterDelay:5.0]; 這會在你的應用程序打開時生成,5秒后它將運行你在延遲方法中放置的所有內容。 所以,當你想讓UINavigationBar變得透明時,我會找到第二個或亂七八糟的東西,你可以很容易地找到使UINavigationBar透明的代碼,但我不知道它在我的頭腦中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.