Initial commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// UINavigationBar+Custom.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/13.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
#import <objc/runtime.h>
|
||||
#import "UINavigationBar+Custom.h"
|
||||
static char overlayKey;
|
||||
|
||||
@implementation UINavigationBar (Custom)
|
||||
- (UIView *)overlay
|
||||
{
|
||||
return objc_getAssociatedObject(self, &overlayKey);
|
||||
}
|
||||
|
||||
- (void)setOverlay:(UIView *)overlay
|
||||
{
|
||||
objc_setAssociatedObject(self, &overlayKey, overlay, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)cnSetBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
if (!self.overlay) {
|
||||
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
||||
self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, CGRectGetHeight(self.bounds) + 20)];
|
||||
self.overlay.userInteractionEnabled = NO;
|
||||
self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
[self insertSubview:self.overlay atIndex:0];
|
||||
}
|
||||
|
||||
self.overlay.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
- (void)cnReset
|
||||
{
|
||||
|
||||
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
||||
[self.overlay removeFromSuperview];
|
||||
self.overlay = nil;
|
||||
}
|
||||
|
||||
-(void)setClearNav
|
||||
{
|
||||
|
||||
[self setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
|
||||
//设置那条横线直接隐藏
|
||||
self.shadowImage = [[UIImage alloc] init];
|
||||
if (self.overlay) {
|
||||
[self.overlay removeFromSuperview];
|
||||
self.overlay = nil;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)resetBackgroundImage{
|
||||
|
||||
[self setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user