YHTransitionKit
分类实现自定义push/pop动画,自定义pop全屏返回手势,navigationBar属性根据vc平滑过渡,无侵入性,低耦合性,使用更加便捷。
演示
安装
CocoaPods (推荐)
打开 Podfile 并编辑:
pod 'YHTransitionKit/NavigationBar', :git => 'https://github.com/yelinux/YHTransitionKit.git'
执行命令 pod install or pod update.
手动
把 YHTransitionKit/Classes/NavigationBar 文件夹拖进你的项目.
使用
- UINavigationController's push/pop 的动画和手势:
#import "YHNavigationKit.h"
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
//导航栏全局设置
nav.yh_interactivePopType = YHNavigationInteractivePopTypeFullScreen;//全屏右滑返回手势(选设)
nav.yh_pushPopAnimated = [[YHNavigationScaleAnimated alloc] init];//自定义动画(全屏右滑返回必设,其它情况选设)
nav.yh_navBackgroundColor = [UIColor colorWithRed:20/255.0 green:122/255.0 blue:244/255.0 alpha:1];//背景颜色(选设)
nav.yh_titleTextAttributes = @{NSForegroundColorAttributeName:UIColor.whiteColor};//标题文本属性(选设)
nav.yh_shadowColor = UIColor.blueColor;//分割线颜色(选设)
nav.navigationBar.translucent = NO;
- UIViewController's navigationBar 的样式设置:
#import "YHNavigationKit.h"
@interface YHSecondViewController ()
@end
@implementation YHSecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//特殊设置
self.yh_prefersNavigationBarType = YHViewControllerNavigationBarTypeShow;//导航栏是否显示(必设)
self.yh_navBackgroundColor = [UIColor colorWithRed:220/255.0 green:189/255.0 blue:206/255.0 alpha:1];//导航栏背景颜色(选设)
self.yh_titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithRed:20/255.0 green:122/255.0 blue:244/255.0 alpha:1]};//标题文本属性(选设)
// self.yh_backgroundImage = [UIImage imageNamed:@"nav_bg_image"];//导航栏背景图片(选设)
self.yh_shadowColor = UIColor.grayColor;//导航栏分割线颜色(选设)
}
源码
作者
WeChat:chenyehong666888, E-mail:ichenevan@126.com
License
YHTransitionKit is available under the MIT license. See the LICENSE file for more info.