Git Product home page Git Product logo

gydnavigationbar's Introduction

GYDNavigationBar

一款解决导航栏渐变的组件

描述

开发中我们经常会遇到导航栏透明度的问题,有时候非常难解决。此组件就是为解决上述问题所产生的。用起来很方便。

效果

使用方法

在你需要改变导航栏透明度的地方导入UIViewController+GYDNav.h

- (void)viewDidLoad {
    [super viewDidLoad];
    self.d_navBarAlpha = 0.5;
    [self.navigationController d_setNavigationBarAlpha:0.5];
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    BTableViewController *vc = [[BTableViewController alloc] init];
    [self.navigationController d_pushViewController:vc fromAlpha:self.d_navBarAlpha toAlpha:0];
}

API

公开的API有:

@interface UIViewController (GYDNav)

/**
 当前navigationBar的透明度 默认1.0
 */
@property (nonatomic, assign) CGFloat d_navBarAlpha;


/**
 是否启用全屏侧滑返回 默认YES
 */
@property (nonatomic, assign) BOOL d_fullScreenEnable;



@end


@interface UINavigationController (GYDNav)


/**
 设置导航栏的alpha 
 
 @param alpha 透明度
 */
- (void)d_setNavigationBarAlpha:(CGFloat)alpha;


/**
 设置导航栏线是否隐藏

 @param hidden 是否隐藏
 */
- (void)d_setShaowViewHidden:(BOOL)hidden;


/**
 在push下一个控制器之前 添加转场动画代理 动态地修改导航栏的alpha 防止突兀

 @param viewController toViewController
 @param fromAlpha 上一个控制器所持有的Alpha
 @param toAlpha 下一个控制器所持有的Alpha
 */
- (void)d_pushViewController:(UIViewController *)viewController fromAlpha:(CGFloat)fromAlpha toAlpha:(CGFloat)toAlpha;


@end

注意

如果你不设置当前控制器的d_navBarAlpha透明度,默认为1.0

1.1版本以后添加全屏侧滑返回手势,返回手势依旧使用系统自带的手势。在你不需要全屏侧滑返回的时候,你需要这样做

- (void)viewDidLoad {
    [super viewDidLoad];
    //取消全屏侧滑返回
    self.d_fullScreenEnable = NO;
}

如果你发现有什么BUG,欢迎随时Issues

gydnavigationbar's People

Contributors

guiyongdong avatar

Watchers

Michael.Yang avatar  avatar

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.