Giter VIP home page Giter VIP logo

wangrui460 / wrnavigationbar Goto Github PK

View Code? Open in Web Editor NEW
3.0K 64.0 602.0 62.93 MB

超简单!!! 一行代码设置状态栏、导航栏按钮、标题、颜色、透明度,移动等 WRNavigationBar which allows you to change NavigationBar's appearance dynamically

Home Page: http://www.jianshu.com/p/540a7e6f7b40

License: MIT License

Objective-C 98.99% Ruby 1.01%
navigationbar navigation scroll alpha ltnavigationbar statusbar title customnavigation

wrnavigationbar's Introduction

image


iOS 技术交流

我创建了一个 微信 iOS 技术交流群,欢迎小伙伴们加入一起交流学习~

可以加我微信我拉你进去(备注iOS),我的微信号 wr1204607318

Requirements

  • iOS 7.0+
  • Xcode 8+

Demo

拉钩App首页 新浪微博个人中心 qq空间 知乎日报
QQ我的资料页 蚂蚁森林 连续多个界面导航栏透明 移动导航栏

Installation

CocoaPods pod 'WRNavigationBar','~>1.4.0’ 如果未发现 1.4.0 请更新一下pod

手动拖入 将 WRNavigationBar 文件夹拽入项目中,导入头文件:#import "WRNavigationBar.h"

Use

✨✨ 一定要看 Demo 中的 AppDelegate 文件 ✨✨


// 设置是 全局使用WRNavigationBar,还是局部使用WRNavigationBar,目前默认是全局使用 (局部使用待开发)
[WRNavigationBar wr_widely];
// WRNavigationBar 不会对 blackList 中的控制器有影响
[WRNavigationBar wr_setBlacklist:@[@"SpecialController",
				 @"TZPhotoPickerController",
				 @"TZGifPhotoPreviewController",
				 @"TZAlbumPickerController",
				 @"TZPhotoPreviewController",
				 @"TZVideoPlayerController"]];

// 一行代码搞定导航栏颜色
[self wr_setNavBarBarTintColor:[UIColor whiteColor]];
// 一行代码搞定导航栏透明度
[self wr_setNavBarBackgroundAlpha:alpha];
// 一行代码搞定导航栏两边按钮颜色
[self wr_setNavBarTintColor:[UIColor whiteColor]];
// 一行代码搞定导航栏上标题颜色
[self wr_setNavBarTitleColor:[UIColor whiteColor]];
// 一行代码搞定状态栏是 default 还是 lightContent
[self wr_setStatusBarStyle:UIStatusBarStyleLightContent];
// 一行代码搞定导航栏底部分割线是否隐藏
[self wr_setNavBarShadowImageHidden:YES];

// 设置导航栏默认的背景颜色
[WRNavigationBar wr_setDefaultNavBarBarTintColor:MainNavBarColor];
// 设置导航栏所有按钮的默认颜色
[WRNavigationBar wr_setDefaultNavBarTintColor:[UIColor whiteColor]];
// 设置导航栏标题默认颜色
[WRNavigationBar wr_setDefaultNavBarTitleColor:[UIColor whiteColor]];
// 统一设置状态栏样式
[WRNavigationBar wr_setDefaultStatusBarStyle:UIStatusBarStyleLightContent];
// 如果需要设置导航栏底部分割线隐藏,可以在这里统一设置
[WRNavigationBar wr_setDefaultNavBarShadowImageHidden:YES];

License

WRNavigationBar is available under the MIT license. See the LICENSE file for more info.

wrnavigationbar's People

Contributors

cx478815108 avatar felixyin66 avatar hefeiking avatar jiguangkj avatar wangrui460 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wrnavigationbar's Issues

pop回来导航栏不透明问题

我在本页面push到一个透明导航栏的页面再pop回来发现导航栏如下图问题
1f772036-bc83-45df-b03e-78146a9e3988
001d8c9e-6579-467d-9d4a-84bfd223c105
请问这个是什么问题呢?求大神指点

如果导航栏是背景图片

如果导航栏是背景图片、只要导入进去,所有的二级导航页面都被变成默认。。。 我没看具体代码实现 猜测用runtime 机制了

影响系统方法设置导航条的title的forecolor

测试,在集成框架后,不能通过原始方法
NSMutableDictionary *att = [NSMutableDictionary dictionary];
att[NSFontAttributeName] = [UIFont systemFontOfSize:18];
att[NSForegroundColorAttributeName] = UIColorFromRGB(0x00cccc);
[appearance setTitleTextAttributes:att];
或者 [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}];
设置title的颜色,但是可以设置font。 找了好久原因。。。。。

iOS11会失效

猜是在iOS11下 _UIBarBackround的alpha最后又被系统设成了1,时机问题。

wr_pushViewController:不执行

你好,我tabbar 控制的导航条是用storyborad 布局的, 但是用你的实现,这句方法不执行,为什么
wr_pushViewController:(UIViewController *)viewController animated:(BOOL)animated

你的方法,是当push 设置为yes才能执行,所以一直卡在这里 不能调用次方法里面的内容

小需求 !

看了你的demo,效果太棒了!
但是,系统的返回箭头很粗,如何实现当下版本支付宝蚂蚁森林页面返回那种细小的 “返回箭头” ?
有什么办法吗?

有个问题请教下

直接在tab接到界面上,导航栏变成白色的了,啥都不显示,跟踪了下代码,if和else都没有进去,但是通过其它界面导航进来没问题,这是为什么?

  • (void)wr_setNavBarBarTintColor:(UIColor *)color
    {
    objc_setAssociatedObject(self, &kWRNavBarBarTintColorKey, color, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    UIView *view = [self wr_customNavBar];
    if ([[self wr_customNavBar] isKindOfClass:[UINavigationBar class]])
    {
    UINavigationBar *navBar = (UINavigationBar *)[self wr_customNavBar];
    [navBar wr_setBackgroundColor:color];
    }
    else
    {
    if ([self pushToCurrentVCFinished] == YES && [self pushToNextVCFinished] == NO) {
    [self.navigationController setNeedsNavigationBarUpdateForBarTintColor:color];
    }
    }
    }

Push/Pop导航栏背景颜色变化进度不准确

CATransaction setAnimationDuration:wrPopDuration];
[CATransaction begin];
NSArray<UIViewController *> *vcs = [self wr_popToViewController:viewController animated:animated];
[CATransaction commit];

这个代码[CATransaction setAnimationDuration:wrPopDuration];设置没有效果,
因为后面 [self wr_popToViewController:viewController animated:animated];调用了系统的方法,把你之前的commit覆盖掉,这个pop的动画时间好像永远都是0.5秒,wrPopDisplayCount打印出来一直是31
在模拟器上设置设置慢速动画可以看出,导航栏颜色变化接近突变。

系统相册页面问题

跳转选择相册UIImagePickerController 页面,[picker navigationBar].titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:17]}; [picker.navigationBar setTintColor:[UIColor blackColor]];
更改相册导航栏颜色代码无效

有个小bug,麻烦您看下哈~

当window的rootViewController是UITabbarController时,UITabbarController包含几个UINavigationController 这时候 第一个 UINavigationController中的VC设置 [self wr_setNavBarBackgroundAlpha:0]; 但是导航栏的Alpha不是0。。

关于iOS11适配的问题

跳转到地问个控制器之后,本来设置了进去导航栏透明度为0,在iOS11系统下已失效。

导航栏底部出现黑线

使用下面的代码无法去除导航栏底部的黑线
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.