CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

STNavigationBar 0.1.2

STNavigationBar 0.1.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2017

Maintained by Scott_Mr.



  • By
  • Scott_Mr

license pod pod pod

简介

一行代码设置状态栏样式和导航栏背景颜色、标题、按钮、透明度以及全屏pop手势支持。

特性

  • 为每个控制器定制了UINavigationBar支持(颜色、透明度、字体大小)
  • 全屏pop手势返回
  • 为单个控制器关闭pop手势支持
  • 自定义pop手势范围
  • 支持自定义UINavigationBar

Demo

蚂蚁森林
QQ空间
知乎日报
新浪微博
自定义导航栏

要求

iOS 8.0+

Xcode 8.0+

安装

  • Cocoapods

    1. podfile里面添加pod 'STNavigationBar', '~> 版本号'
    2. pod install
  • 手动拖入

    下载代码并将STNavigaionBar文件夹拖入到项目中,导入头文件#import "STNavigationBar.h"即可。

使用说明

建议在AppDelegate里全局设置导航栏以及状态栏样式。

  • 设置全局导航栏样式
[UIColor st_setDefaultNavigationBarBarTintColor:STMainNavBarColor];
[UIColor st_setDefaultNavigationBarTintColor:STNaviBarTintColor];
[UIColor st_setDefaultNavigationBarTitleColor:STNaviBarTitleColor];
[UIColor st_setDefaultStatusBarStyle:UIStatusBarStyleLightContent];
  • 设置单个控制器导航栏样式
// 设置导航栏两边按钮颜色
[self st_setNavigationBarTintColor:[UIColor whiteColor]];
// 设置导航栏标题颜色
[self st_setNavigationBarTitleColor:[UIColor blackColor]];
// 设置状态栏样式
[self st_setStatusBarStyle:UIStatusBarStyleDefault];
// 设置导航栏透明度
[self st_setNavigationBarBackgroundAlpha:0];
// 设置导航栏背景颜色
[self st_setNavigationBarTitleColor:[UIColor whiteColor]];
  • 开启/关闭手势返回
// YES:关闭手势/NO:开启手势
[self st_setInteractivePopDisabled:YES];
  • 指定手势返回范围
[self st_setInteractivePopMaxAllowedInitialDistanceToLeftEdge:30.0];
  • 解决UIScrollView和手势pop冲突
// 自定义一个UIScrollView,实现如下方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    if (self.contentOffset.x <= 0) {
        if ([otherGestureRecognizer.delegate isKindOfClass:[STFullscreenPopGestureRecognizerDelegate class]]) {
            return YES;
        }
    }
    return NO;
}

联系

  • 如果你发现了bug,请帮我提交issue。
  • 如果你有好的建议,请帮我提交issue。
  • 如果你想贡献代码,请提交请求。

许可证

STNavigationBar 是基于 MIT 许可证下发布的,详情请参见 LICENSE