//  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. C++基础内容复习

    下列语句定义了5个变量: int count; double sales_price,sum; std::string title; Sales_item bookItem; 每个定义都是以类型说明符 ...

  2. win32_11gR2_database安装教程

  3. 【JUnit 报错】java.lang.IncompatibleClassChangeError

    使用Junit 测试spring时候报错: java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVa ...

  4. 字符编码GB2312、GBK、UTF-8的区别

    本文来自:javaeye网站 UTF8是国际编码,它的通用性比较好,外国人也可以浏览论坛 GBK是国家编码,通用性比UTF8差,不过UTF8占用的数据库比GBK大~ 提示:如果您的网站客户群体主要是面 ...

  5. GC日志介绍

    每一种收集器的日志形式都是由它们自身的实现所决定的,换而言之,每个收集器的日志格式都可以不一样.但虚拟机设计者为了方便用户阅读,将各个收集器的日志都维持一定的共性,例如以下两段典型的GC日志: 33. ...

  6. Python实践:开篇

    一.概述 Python实践 是应用Python解决实际问题的案例集合,这些案例中的Python应用通常 功能各异.大小不一. 该系列文章是本人应用Python的实践总结,会不定期更新. 二.目录 Py ...

  7. 分享Kali Linux 2016.2第36周镜像虚拟机

    分享Kali Linux 2016.2第36周镜像虚拟机   9月9日,Kali Linux官方发布Kali Linux 2016.2周更新镜像.今天以64位镜像安装了一个虚拟机,分享给大家.该虚拟机 ...

  8. Codeforces 498C Array and Operations(最大流)

    题目是给一些数和<数对>的下标,然后进行操作:对某个<数对>中的两个数同时除以一个都能被它们整除且不等于1的数,要求的就是最多能进行多少次操作. 除数一定是素数,就是要决定某素 ...

  9. clumsy 0.1 测试工具(延迟\掉包\节流\重发\乱序\篡改)

    clumsy : http://jagt.github.io/clumsy/可以模拟以下几种场景: 延迟(Lag),把数据包缓存一段时间后再发出,这样能够模拟网络延迟的状况. 掉包(Drop),随机丢 ...

  10. CSS一些总结

    1. display block:块元素,默认宽度为100%,可以设置元素的宽高,默认占满一行.块元素包括div,h1-h6,form,table,ul,ol等: inline:行内元素,默认宽度为内 ...