GithubHelp home page GithubHelp logo

ccnavigationbar's Introduction

介绍

简易的iOS导航栏颜色渐变方案,通过新增category并利用runtime的method swizzling实现两行代码轻松搞定。

简洁的API:

/** 默认方法,临界值为200
 *  @param color 最终显示颜色
 *  @param scrollView 滑动视图
 */
- (void)changeColor:(UIColor *)color scrolllView:(UIScrollView *)scrollView;

/** 自定义方法,可设置临界值
 *  @param color 最终显示颜色
 *  @param scrollView 滑动视图
 *  @param value 临界值
 */
- (void)changeColor:(UIColor *)color scrolllView:(UIScrollView *)scrollView criticalValue:(CGFloat)va

用法

在viewController中导入头文件:#import "UIViewController+CCNav.h"

在对应方法中写上一下两行代码:

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    // 第一行代码:手动触发计算当前导航栏颜色
    [self scrollViewDidScroll:self.tableView];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    // 第二行代码:滑动中计算导航栏颜色
    [self changeColor:[UIColor redColor] scrolllView:scrollView];
}

原理可参考为之前版本写的文章:简易的iOS导航栏颜色渐变方案

ccnavigationbar's People

Contributors

rachalzhou avatar

Stargazers

 avatar RyanCao avatar kims avatar 公众号:iOS逆向 avatar  avatar lianpeng527 avatar  avatar 卡卡西 avatar dkdsj avatar zhaowei avatar Carvin725 avatar  avatar LQ avatar Yueqian Zhang avatar  avatar  avatar 王颖博 avatar Jivan avatar  avatar  avatar  avatar  avatar  avatar 林海雪原 avatar  avatar 闲羽 avatar TableView avatar Sophia Mitchell avatar  avatar web avatar  avatar  avatar  avatar  avatar Be better! avatar xiaodiaosi avatar LATTICE avatar 火火 avatar

Watchers

 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.