Skip to content

Commit

Permalink
update podspec and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrui460 committed Jan 19, 2018
1 parent 460182d commit 28594e2
Show file tree
Hide file tree
Showing 4 changed files with 310 additions and 258 deletions.
4 changes: 2 additions & 2 deletions WRNavigationBar.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Pod::Spec.new do |s|

s.name = "WRNavigationBar"
s.version = "1.1.0"
s.version = "1.2.0"
s.summary = "navigationBar statusBar alpha color"
s.homepage = "https://github.com/wangrui460/WRNavigationBar"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "wangrui460" => "wangruidev@gmail.com" }
s.social_media_url = "http://weibo.com/wangrui460"
s.platform = :ios, "8.0"
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/wangrui460/WRNavigationBar.git", :tag => s.version }
s.source_files = "WRNavigationBar/*.{h,m}"
s.requires_arc = true
Expand Down
41 changes: 18 additions & 23 deletions WRNavigationBar/WRCustomNavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Github地址:https://github.com/wangrui460/WRNavigationBar

#import "WRCustomNavigationBar.h"
#import "sys/utsname.h"

#define kWRDefaultTitleSize 18
#define kWRDefaultTitleColor [UIColor blackColor]
Expand All @@ -31,8 +32,7 @@ - (void)wr_toLastViewController
}
}

+ (UIViewController*)wr_currentViewController
{
+ (UIViewController*)wr_currentViewController {
UIViewController* rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
return [self wr_currentViewControllerFrom:rootViewController];
}
Expand Down Expand Up @@ -85,8 +85,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
return self;
}

-(void)setupView
{
-(void)setupView {
[self addSubview:self.backgroundView];
[self addSubview:self.backgroundImageView];
[self addSubview:self.leftButton];
Expand All @@ -99,8 +98,7 @@ -(void)setupView
}

// TODO:这边结合 WRCellView 会不会更好呢?
-(void)updateFrame
{
-(void)updateFrame {
NSInteger top = ([WRCustomNavigationBar isIphoneX]) ? 44 : 20;
NSInteger margin = 0;
NSInteger buttonHeight = 44;
Expand Down Expand Up @@ -148,8 +146,7 @@ - (void)wr_setTintColor:(UIColor *)color {
}

#pragma mark - 左右按钮
- (void)wr_setLeftButtonWithNormal:(UIImage *)normal highlighted:(UIImage *)highlighted title:(NSString *)title titleColor:(UIColor *)titleColor
{
- (void)wr_setLeftButtonWithNormal:(UIImage *)normal highlighted:(UIImage *)highlighted title:(NSString *)title titleColor:(UIColor *)titleColor {
self.leftButton.hidden = NO;
[self.leftButton setImage:normal forState:UIControlStateNormal];
[self.leftButton setImage:highlighted forState:UIControlStateHighlighted];
Expand All @@ -169,8 +166,7 @@ - (void)wr_setLeftButtonWithTitle:(NSString *)title titleColor:(UIColor *)titleC
[self wr_setLeftButtonWithNormal:nil highlighted:nil title:title titleColor:titleColor];
}

- (void)wr_setRightButtonWithNormal:(UIImage *)normal highlighted:(UIImage *)highlighted title:(NSString *)title titleColor:(UIColor *)titleColor
{
- (void)wr_setRightButtonWithNormal:(UIImage *)normal highlighted:(UIImage *)highlighted title:(NSString *)title titleColor:(UIColor *)titleColor {
self.rightButton.hidden = NO;
[self.rightButton setImage:normal forState:UIControlStateNormal];
[self.rightButton setImage:highlighted forState:UIControlStateHighlighted];
Expand Down Expand Up @@ -268,21 +264,20 @@ -(UIImageView *)backgroundImageView {
return _backgroundImageView;
}

+ (int)navBarBottom
{
if ([WRCustomNavigationBar isIphoneX]) {
return 88;
} else {
return 64;
}
+ (int)navBarBottom {
return 44 + CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
}
+ (BOOL)isIphoneX
{
if (CGRectEqualToRect([UIScreen mainScreen].bounds,CGRectMake(0, 0, 375, 812))) {
return YES;
} else {
return NO;
+ (BOOL)isIphoneX {
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"]) {
// judgment by height when in simulators
return (CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812)) ||
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(812, 375)));
}
BOOL isIPhoneX = [platform isEqualToString:@"iPhone10,3"] || [platform isEqualToString:@"iPhone10,6"];
return isIPhoneX;
}

@end
Expand Down
18 changes: 14 additions & 4 deletions WRNavigationBar/WRNavigationBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,26 @@

@interface WRNavigationBar : UIView
+ (BOOL)isIphoneX;
+ (int)navBarBottom;
+ (int)tabBarHeight;
+ (int)screenWidth;
+ (int)screenHeight;
+ (CGFloat)navBarBottom;
+ (CGFloat)tabBarHeight;
+ (CGFloat)screenWidth;
+ (CGFloat)screenHeight;
@end


#pragma mark - Default
@interface WRNavigationBar (WRDefault)

/// 局部使用该库 待开发
//+ (void)wr_local;
/// 广泛使用该库 default 暂时是默认, wr_local 完成后,wr_local就会变成默认
+ (void)wr_widely;

/// 局部使用该库时,设置需要用到的控制器 待开发
//+ (void)wr_setWhitelist:(NSArray<NSString *> *)list;
/// 广泛使用该库时,设置需要屏蔽的控制器
+ (void)wr_setBlacklist:(NSArray<NSString *> *)list;

/** set default barTintColor of UINavigationBar */
+ (void)wr_setDefaultNavBarBarTintColor:(UIColor *)color;

Expand Down
Loading

0 comments on commit 28594e2

Please sign in to comment.