//  CustomTabBarViewController.h

#import <UIKit/UIKit.h>
@interface CustomTabBarViewController : UITabBarController + (void)deallocTabbar;
+ (id)defaultsTabBar; - (void)selectBUttonWithIndex:(NSInteger)index;
-(void)setTabBarHidden:(BOOL)Bool;
@end
//
// CustomTabBarViewController.m
#import "CustomTabBarViewController.h"
#import "DJSHomeViewController.h"
#import "DJSStudioViewController.h"
#import "DJSAppointmentViewController.h"
#import "DJSMineViewController.h"
#import "Header.h"
#define btnBaseTag 100 static CustomTabBarViewController *defaults;
@interface CustomTabBarViewController ()
{
BOOL tabBarIsShow;
}
@property (nonatomic, strong) UIImageView *baceGroundImage;
@property (nonatomic, strong) NSMutableArray *btnArray; @end @implementation CustomTabBarViewController
@synthesize baceGroundImage, btnArray;
+ (void)deallocTabbar
{
defaults = nil;
}
+ (id)defaultsTabBar
{
if (defaults == nil) {
defaults = [[CustomTabBarViewController alloc] init];
}
return defaults;
} - (void)viewDidLoad {
[super viewDidLoad]; tabBarIsShow = YES;
self.view.backgroundColor = [UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:];
self.tabBar.hidden = YES;
DJSHomeViewController *home = [[DJSHomeViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:home];
DJSStudioViewController *produce = [[DJSStudioViewController alloc]init];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:produce]; DJSAppointmentViewController *appoint = [[DJSAppointmentViewController alloc]init];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:appoint]; DJSMineViewController *mine = [[DJSMineViewController alloc]init];
UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:mine]; self.viewControllers = @[nav, nav1, nav2, nav3]; btnArray = [[NSMutableArray alloc] init];
[self setCustomTabbarItem];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)setCustomTabbarItem
{
[btnArray removeAllObjects];
baceGroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(, Main_height-, Main_Width, )];
baceGroundImage.backgroundColor = [UIColor whiteColor]; baceGroundImage.image = [UIImage imageNamed:@"wireframe_bottom@2x"];
baceGroundImage.userInteractionEnabled = YES;
[self.view addSubview:baceGroundImage]; // UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Width, 0.5)];
// lineView.backgroundColor = [UIColor cyanColor];
// [baceGroundImage addSubview:lineView];
NSArray *imageNameArr = @[@"home_unicorn_unpress", @"home_project_unpress", @"home_studio_unpress",@"home_my_unpress"];
NSArray *selecNameArr = @[@"home_unicorn_press", @"home_project_press", @"home_studio_press",@"home_my_press"];
CGFloat space = Main_Width/;
for (NSInteger i = ; i < ; i++) {
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(i * space, , space, )];
// btn.backgroundColor = [UIColor cyanColor];
[btn setImage:[UIImage imageNamed:imageNameArr[i]] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:selecNameArr[i]] forState:UIControlStateSelected];
btn.tag = btnBaseTag + i;
if (i == )
{
btn.selected = YES;
}
[btn addTarget:self action:@selector(pressBtn:) forControlEvents:UIControlEventTouchUpInside];
[baceGroundImage addSubview:btn];
[btnArray addObject:btn];
}
}
- (void)selectBUttonWithIndex:(NSInteger)index
{
UIButton *btn = (UIButton *)btnArray[index];
[self pressBtn:btn];
} -(void)setTabBarHidden:(BOOL)Bool
{ if (Bool) {
[self hideTabBar];
}
else{
[self showTabBar];
}
} - (void)hideTabBar {
if (!tabBarIsShow)
{ //already hidden
return;
}
[UIView animateWithDuration:0.35 animations:^{
baceGroundImage.frame = CGRectMake(, Main_height, Main_Width, );
}];
tabBarIsShow = NO;
} - (void)showTabBar {
if (tabBarIsShow)
{ // already showing
return;
}
[UIView animateWithDuration:0.35 animations:^{
baceGroundImage.frame = CGRectMake(, Main_height-, Main_Width, );
}]; tabBarIsShow = YES;
} -(void)pressBtn:(id)sender
{
UIButton *btn=(UIButton *)sender; if (btn.tag - btnBaseTag >= self.viewControllers.count) {
return;
}
self.selectedIndex = btn.tag - btnBaseTag;
for (UIButton *tempBtn in btnArray)
{
if (tempBtn.tag == btn.tag)
{
tempBtn.selected=YES;
}
else
{
tempBtn.selected=NO;
}
}
}
@end

1、创建

@interface AppDelegate ()
{
    CustomTabBarViewController *tabbar;
}

tabbar=[CustomTabBarViewController defaultsTabBar];

self.window.rootViewController = tabbar;
2、隐藏

CustomTabBarViewController * tabBar =[CustomTabBarViewController defaultsTabBar];
    [tabBar setTabBarHidden:YES];

TabBarViewController的创建以及渐变隐藏的更多相关文章

  1. CSS字体渐变 & 隐藏浏览器滚动条 & grid布局(转载)

    字体渐变  https://www.zhangxinxu.com/study/201104/css3-text-gradient-2.html 隐藏浏览器滚动条  https://blog.csdn. ...

  2. canvas 创建颜色渐变柱状图

    最终结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...

  3. css实现内容渐变隐藏效果,手机网页版知乎内容隐藏效果的实现

    看到一个需求,如下图,知乎手机网页版的一个视觉效果,对内容很长的部分有一个渐变的隐藏的效果,个人觉得这个设计还是很好的,符合手机大小的应用场景,没有一下子显示完全,可以很快的滑倒页面底部,一定程度上减 ...

  4. Vuforia图像追踪,动态创建的对象隐藏显示的坑

    刚做的一个项目,使用Unity3D的Vuforia插件进行图像识别,其中有动态生成的游戏对象模型,地形模型放在ImageTarget下,作为ImageTarget的子物体. 动态生成的敌人则有Pref ...

  5. iOS开发之创建颜色渐变视图View

    在iOS开发中有时需要自己自定义一个视图view的背景,而网上有人提出的在循环中不断alloc的方法设置其背景色渐变,会耗费很多内存和资源,极其不明智,而在CALayer中早就提供有图层渐变的类和相应 ...

  6. svg和css3创建环形渐变进度条

    在负责的项目中,有一个环形渐变读取进度的效果的需求,于是在网上查阅相关资料整理一下.代码如下: <!DOCTYPE html> <html lang="en"&g ...

  7. Ionic2 渐变隐藏导航栏|标题栏

    废话少说 直接上代码.... //导入需要用到的命名空间 ViewChild,Content import { Component, ViewChild } from '@angular/core'; ...

  8. IOS 创建渐变图层

    代码如下 typedef enum { GradientLayerKindLeftRight = , GradientLayerKindUpDown, GradientLayerKindLBRT,// ...

  9. canvas 创建渐变图形

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

随机推荐

  1. popular net

    陈皓<跟我一起写makefile>http://blog.csdn.net/haoel/article/details/2886/

  2. 归并排序的分析与Java实现

    归并操作(merge),也叫归并算法,指的是将两个已经排序的序列合并成一个序列的操作.归并排序算法依赖归并操作.该算法是采用分治法(Divide and Conquer)的一个非常典型的应用.归并排序 ...

  3. Emacs简易教程

    Emacs简易教程阅读: 命令: $emacs 进入之后,输入: C-h t 这里,C-h表示按住[Ctrl]键的同时按h ####### 20090620 *退出: 输入“C-x C-c” *撤销: ...

  4. 在ubuntu 14.04 64位系统上安装32位库

    转自:http://www.enjoydiy.com/2937.html 有些软件还是依赖32位的库,但是64位的系统已经成为现在的主流.以前的ubuntu可以通过下面的命令安装:           ...

  5. 微信公众平台开发3:订阅事件subscribe处理

    新用户关注微信公众平台,将产生一个订阅事件,即subscribe事件,默认代码中没有对这一事件进行相应处理. 在新用户关注公众平台后,可能想知道该平台提供了哪些功能,以及怎样使用该平台,通俗一点讲就是 ...

  6. Github排行榜

    http://githubranking.com/ 中国区开发者排行榜: http://githubrank.com/ 也可以在官网查询: https://github.com/search?q=st ...

  7. Android 编程下短信监听在小米手机中失效的解决办法

    相信很多人写的短信监听应用在小米手机上是拦截不到短信的,这是因为小米对短信的处置权优先分给了系统.我们可以在短信的[设置]→[高级设置]→[系统短信优先]中发现短信的优先处理权默认是分给系统的,只要关 ...

  8. 前端JSON使用总结

    JSON: JavaScript Object Notation(JavaScript 对象表示法)的简称. 1. 什么是 JSON ? JSON 指的是 JavaScript 对象表示法(JavaS ...

  9. 使用“Empty 模式”改进 Null Object

    概述 Null Object 是Martin 大师提出的一种重构手段,其思想就是通过多态(派生一个Null对象)来减少逻辑(if … then …else)的判断. 而.NET中已经有Null Obj ...

  10. python 代码片段8

    #coding=utf-8 # 列表推倒式子 data=[x+1 for x in range(10)] print data even_numbers=[x for x in range(10) i ...