Skip to content

Commit 3ead3c4

Browse files
committed
update~
1 parent 7695f90 commit 3ead3c4

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

WRNavigationBar/WRNavigationBar.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,8 @@ extension UIViewController: WRAwakeProtocol
569569
// let navBar = customNavBar as! UINavigationBar
570570
// navBar.wr_setBackgroundColor(color: newValue)
571571
}
572-
else
573-
{
574-
let isRootViewController = self.navigationController?.viewControllers.first == self
575-
if (pushToCurrentVCFinished == true || isRootViewController == true) && pushToNextVCFinished == false {
572+
else {
573+
if canUpdateNavBarBarTintColorOrBackgroundAlpha == true {
576574
navigationController?.setNeedsNavigationBarUpdate(barTintColor: newValue)
577575
}
578576
}
@@ -594,14 +592,23 @@ extension UIViewController: WRAwakeProtocol
594592
// let navBar = customNavBar as! UINavigationBar
595593
// navBar.wr_setBackgroundAlpha(alpha: newValue)
596594
}
597-
else
598-
{
599-
if pushToCurrentVCFinished == true && pushToNextVCFinished == false {
595+
else {
596+
if canUpdateNavBarBarTintColorOrBackgroundAlpha == true {
600597
navigationController?.setNeedsNavigationBarUpdate(barBackgroundAlpha: newValue)
601598
}
602599
}
603600
}
604601
}
602+
private var canUpdateNavBarBarTintColorOrBackgroundAlpha:Bool {
603+
get {
604+
let isRootViewController = self.navigationController?.viewControllers.first == self
605+
if (pushToCurrentVCFinished == true || isRootViewController == true) && pushToNextVCFinished == false {
606+
return true
607+
} else {
608+
return false
609+
}
610+
}
611+
}
605612

606613
// navigationBar tintColor
607614
var navBarTintColor: UIColor {
@@ -735,6 +742,10 @@ extension UIViewController: WRAwakeProtocol
735742

736743
@objc func wr_viewDidAppear(_ animated: Bool)
737744
{
745+
746+
if self.navigationController?.viewControllers.first != self {
747+
self.pushToCurrentVCFinished = true
748+
}
738749
if canUpdateNavigationBar() == true
739750
{
740751
if let navBarBgImage = navBarBackgroundImage {

WRNavigationBar_swift/WRNavigationBar_swift/WRNavigationBar/WRNavigationBar.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,8 @@ extension UIViewController: WRAwakeProtocol
569569
// let navBar = customNavBar as! UINavigationBar
570570
// navBar.wr_setBackgroundColor(color: newValue)
571571
}
572-
else
573-
{
574-
let isRootViewController = self.navigationController?.viewControllers.first == self
575-
if (pushToCurrentVCFinished == true || isRootViewController == true) && pushToNextVCFinished == false {
572+
else {
573+
if canUpdateNavBarBarTintColorOrBackgroundAlpha == true {
576574
navigationController?.setNeedsNavigationBarUpdate(barTintColor: newValue)
577575
}
578576
}
@@ -594,14 +592,23 @@ extension UIViewController: WRAwakeProtocol
594592
// let navBar = customNavBar as! UINavigationBar
595593
// navBar.wr_setBackgroundAlpha(alpha: newValue)
596594
}
597-
else
598-
{
599-
if pushToCurrentVCFinished == true && pushToNextVCFinished == false {
595+
else {
596+
if canUpdateNavBarBarTintColorOrBackgroundAlpha == true {
600597
navigationController?.setNeedsNavigationBarUpdate(barBackgroundAlpha: newValue)
601598
}
602599
}
603600
}
604601
}
602+
private var canUpdateNavBarBarTintColorOrBackgroundAlpha:Bool {
603+
get {
604+
let isRootViewController = self.navigationController?.viewControllers.first == self
605+
if (pushToCurrentVCFinished == true || isRootViewController == true) && pushToNextVCFinished == false {
606+
return true
607+
} else {
608+
return false
609+
}
610+
}
611+
}
605612

606613
// navigationBar tintColor
607614
var navBarTintColor: UIColor {
@@ -735,6 +742,10 @@ extension UIViewController: WRAwakeProtocol
735742

736743
@objc func wr_viewDidAppear(_ animated: Bool)
737744
{
745+
746+
if self.navigationController?.viewControllers.first != self {
747+
self.pushToCurrentVCFinished = true
748+
}
738749
if canUpdateNavigationBar() == true
739750
{
740751
if let navBarBgImage = navBarBackgroundImage {

0 commit comments

Comments
 (0)