Skip to content

Commit

Permalink
1.增加了系列的宏定义,建立基本的类RootViewController 所有的子类都继承于此类
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufengyi committed Jul 4, 2015
1 parent bef6e00 commit b6711e7
Show file tree
Hide file tree
Showing 49 changed files with 240 additions and 279 deletions.
13 changes: 0 additions & 13 deletions BaseViewController.h

This file was deleted.

36 changes: 0 additions & 36 deletions BaseViewController.m

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 1,3 @@
# ZFYTabbarController
使用方法:
文件结构
主要宝航了
40 changes: 19 additions & 21 deletions TabBar/BaseNavigationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 8,7 @@

#import "BaseNavigationViewController.h"
#import "UIImage Color.h"
#import "ZFYTabbar.h"
@interface BaseNavigationViewController ()<UINavigationControllerDelegate,UIGestureRecognizerDelegate>

@end
Expand All @@ -17,36 18,33 @@ @implementation BaseNavigationViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationBar.barTintColor =[UIColor whiteColor];
//防止手势失效的解决方案
self.delegate=self;
self.interactivePopGestureRecognizer.delegate=self;
[self.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];
self.navigationBar.tintColor =[UIColor grayColor];
self.navigationBar.translucent = NO;
self.navigationBar.barTintColor = Nav_background_Color;
self.navigationBar.tintColor = Nav_tintColor;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
//设置返回的箭头自定义图片
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
UIImage *backimage =Nav_back_icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backimage];
[[UINavigationBar appearance]setBackIndicatorImage:backimage];
// 去掉返回按钮文字
UIBarButtonItem *baritem =[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
UIOffset offset;
offset.horizontal = -500;
[baritem setBackButtonTitlePositionAdjustment:offset forBarMetrics:UIBarMetricsDefault];
NSDictionary *titleAttributes = [NSDictionary dictionaryWithObjectsAndKeys:Nav_Title_Color,NSForegroundColorAttributeName,Nav_Title_Font,NSFontAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

}
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (self.viewControllers.count>0) {
///第二层viewcontroller 隐藏tabbar
viewController.hidesBottomBarWhenPushed=YES;
//手势的时候隐藏导航栏
// self.hidesBarsOnSwipe=YES;
//修改了返回按钮的样式,但是此时侧滑手势实效
viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:[UIImage imageNamed:@"back_Icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(popViewControllerAnimated:)];
}
[super pushViewController:viewController animated:YES];
}
//重写系统
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
-(void)dealloc
{
self.delegate=nil;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
Expand Down
19 changes: 7 additions & 12 deletions TabBar/CustomController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 11,12 @@
#import "SecondViewController.h"
#import "BaseNavigationViewController.h"
#import "ThirdViewController.h"
#import "UIImage Color.h"

#import "ZFYTabbar.h"
// 字体设置
#define TITLE_NORMAL_COLOR [UIColor colorWithRed:20/255.0 green:20/255.0 blue:120/255.0 alpha:1]
#define TITLE_SELECTED_COLOR [UIColor colorWithRed:20/255.0 green:152/255.0 blue:172/255.0 alpha:1]
#define TITLE_FONT [UIFont fontWithName:@"AmericanTypewriter" size:14.0f]

//#define TITLE_NORMAL_COLOR [UIColor colorWithRed:20/255.0 green:20/255.0 blue:120/255.0 alpha:1]
//#define TITLE_SELECTED_COLOR [UIColor colorWithRed:20/255.0 green:152/255.0 blue:172/255.0 alpha:1]
//#define TITLE_FONT [UIFont fontWithName:@"AmericanTypewriter" size:14.0f]
//
@interface CustomController ()

@end
Expand Down Expand Up @@ -45,12 44,8 @@ - (void)viewDidLoad {
}
self.viewControllers=navigationArray;
UITabBarItem *item = [UITabBarItem appearance];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:TITLE_NORMAL_COLOR, NSFontAttributeName:TITLE_FONT} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:TITLE_SELECTED_COLOR, NSFontAttributeName:TITLE_FONT} forState:UIControlStateSelected];
//设置选择后的高亮
//self.tabBar.selectionIndicatorImage =[UIImage imageNamed:@"[email protected]"];
//设置背景
self.tabBar.backgroundColor = [UIColor blueColor];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:Tab_TITLE_NORMAL_COLOR, NSFontAttributeName:Tab_TITLE_FONT} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:Tab_TITLE_SELECTED_COLOR, NSFontAttributeName:Tab_TITLE_FONT} forState:UIControlStateSelected];
}

- (void)didReceiveMemoryWarning {
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions TabBar/ZFYTabbar.h
Original file line number Diff line number Diff line change
@@ -0,0 1,34 @@
//
// ZFYTabbar.h
// ZFYTabbarController
//
// Created by 朱封毅 on 04/07/15.
// Copyright (c) 2015年 朱封毅. All rights reserved.
//

#ifndef ZFYTabbarController_ZFYTabbar_h
#define ZFYTabbarController_ZFYTabbar_h
#import "UIImage Color.h"

#pragma mark ---Navigation config

//导航栏色调设置
#define Nav_tintColor [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:1];
//导航栏的背景颜色
#define Nav_background_Color [UIColor colorWithRed:180.0/255.0 green:180.0/255.0 blue:180.0/255.0 alpha:1]
//导航栏的标题字体大小
#define Nav_Title_Font [UIFont boldSystemFontOfSize:16]
//导航栏的标题颜色
#define Nav_Title_Color [UIColor colorWithRed:10.0/255.0 green:120.0/255.0 blue:100.0/255.0 alpha:1]
//设置返回按钮的图片
#define Nav_back_icon [[UIImage imageNamed:@"back_Icon.png"]


#pragma mark ---Tabbar config
// 字体设置
#define Tab_TITLE_NORMAL_COLOR [UIColor colorWithRed:20/255.0 green:20/255.0 blue:120/255.0 alpha:1]
#define Tab_TITLE_SELECTED_COLOR [UIColor colorWithRed:20/255.0 green:152/255.0 blue:172/255.0 alpha:1]
#define Tab_TITLE_FONT [UIFont fontWithName:@"AmericanTypewriter" size:14.0f]


#endif
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit b6711e7

Please sign in to comment.