Skip to content

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
EnderTan authored and EnderTan committed Mar 10, 2017
1 parent ed6047f commit a40a59b
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 47 deletions.
4 changes: 2 additions & 2 deletions ETNavBarTransparent.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'ETNavBarTransparent'
s.version = '1.0.5'
s.version = '1.0.6'
s.license = 'MIT'
s.summary = 'Change NavigationBar‘s transparency at pop gestrue and other situation'
s.homepage = 'https://github.com/EnderTan/ETNavBarTransparent'
s.author = { 'Ender Tan' => '[email protected]' }
s.social_media_url = 'http://weibo.com/endertan'
s.source = { :git => 'https://github.com/EnderTan/ETNavBarTransparent.git', :tag => '1.0.5' }
s.source = { :git => 'https://github.com/EnderTan/ETNavBarTransparent.git', :tag => '1.0.6' }
s.platform = :ios, '8.0'
s.source_files = 'ETNavBarTransparent','ETNavBarTransparent/**/*'
s.requires_arc = true
Expand Down
37 changes: 25 additions & 12 deletions ETNavBarTransparent/ETNavBarTransparent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,35 @@ extension UINavigationController {
}

fileprivate func setNeedsNavigationBackground(alpha:CGFloat) {
let barBackgroundView = navigationBar.value(forKey: "_barBackgroundView") as AnyObject
let backgroundImageView = barBackgroundView.value(forKey: "_backgroundImageView") as? UIImageView


let barBackgroundView = navigationBar.subviews[0]
if let shadowView = barBackgroundView.value(forKey: "_shadowView") as? UIView {
shadowView.alpha = alpha
}

if navigationBar.isTranslucent {
if backgroundImageView != nil && backgroundImageView!.image != nil {
(barBackgroundView as! UIView).alpha = alpha
if #available(iOS 10.0, *){
if navigationBar.backgroundImage(for: .default) == nil {
if let backgroundEffectView = barBackgroundView.value(forKey: "_backgroundEffectView") as? UIView {
backgroundEffectView.alpha = alpha
return
}
}

}else{
if let backgroundEffectView = barBackgroundView.value(forKey: "_backgroundEffectView") as? UIView {
backgroundEffectView.alpha = alpha
if let adaptiveBackdrop = barBackgroundView.value(forKey: "_adaptiveBackdrop") as? UIView {
if let backdropEffectView = adaptiveBackdrop.value(forKey: "_backdropEffectView") as? UIView {
backdropEffectView.alpha = alpha
return
}
}
}
}else{
(barBackgroundView as! UIView).alpha = alpha

}

if let shadowView = barBackgroundView.value(forKey: "_shadowView") as? UIView {
shadowView.alpha = alpha
}
barBackgroundView.alpha = alpha

}

Expand Down Expand Up @@ -160,6 +172,7 @@ extension UINavigationController:UINavigationControllerDelegate,UINavigationBarD


public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {

if viewControllers.count >= (navigationBar.items?.count)! {
let popToVC = viewControllers[viewControllers.count-2]
setNeedsNavigationBackground(alpha: (popToVC.navBarBgAlpha))
Expand Down Expand Up @@ -210,7 +223,7 @@ extension UIViewController {

objc_setAssociatedObject(self, &AssociatedKeys.navBarBgAlpha, alpha, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)

//设置UI
//Update UI
navigationController?.setNeedsNavigationBackground(alpha: alpha)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = NAC5X5LCW4;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/ETNavBarTransparentDemo",
);
INFOPLIST_FILE = ETNavBarTransparentDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -292,6 +296,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = NAC5X5LCW4;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/ETNavBarTransparentDemo",
);
INFOPLIST_FILE = ETNavBarTransparentDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,35 @@ extension UINavigationController {
}

fileprivate func setNeedsNavigationBackground(alpha:CGFloat) {
let barBackgroundView = navigationBar.value(forKey: "_barBackgroundView") as AnyObject
let backgroundImageView = barBackgroundView.value(forKey: "_backgroundImageView") as? UIImageView


let barBackgroundView = navigationBar.subviews[0]
if let shadowView = barBackgroundView.value(forKey: "_shadowView") as? UIView {
shadowView.alpha = alpha
}

if navigationBar.isTranslucent {
if backgroundImageView != nil && backgroundImageView!.image != nil {
(barBackgroundView as! UIView).alpha = alpha
if #available(iOS 10.0, *){
if navigationBar.backgroundImage(for: .default) == nil {
if let backgroundEffectView = barBackgroundView.value(forKey: "_backgroundEffectView") as? UIView {
backgroundEffectView.alpha = alpha
return
}
}

}else{
if let backgroundEffectView = barBackgroundView.value(forKey: "_backgroundEffectView") as? UIView {
backgroundEffectView.alpha = alpha
if let adaptiveBackdrop = barBackgroundView.value(forKey: "_adaptiveBackdrop") as? UIView {
if let backdropEffectView = adaptiveBackdrop.value(forKey: "_backdropEffectView") as? UIView {
backdropEffectView.alpha = alpha
return
}
}
}
}else{
(barBackgroundView as! UIView).alpha = alpha

}

if let shadowView = barBackgroundView.value(forKey: "_shadowView") as? UIView {
shadowView.alpha = alpha
}
barBackgroundView.alpha = alpha

}

Expand Down Expand Up @@ -160,6 +172,7 @@ extension UINavigationController:UINavigationControllerDelegate,UINavigationBarD


public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {

if viewControllers.count >= (navigationBar.items?.count)! {
let popToVC = viewControllers[viewControllers.count-2]
setNeedsNavigationBackground(alpha: (popToVC.navBarBgAlpha))
Expand Down Expand Up @@ -210,7 +223,7 @@ extension UIViewController {

objc_setAssociatedObject(self, &AssociatedKeys.navBarBgAlpha, alpha, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)

//设置UI
//Update UI
navigationController?.setNeedsNavigationBackground(alpha: alpha)
}
}
Expand Down

0 comments on commit a40a59b

Please sign in to comment.