TabBarViewController的创建以及渐变隐藏
// 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的创建以及渐变隐藏的更多相关文章
- CSS字体渐变 & 隐藏浏览器滚动条 & grid布局(转载)
字体渐变 https://www.zhangxinxu.com/study/201104/css3-text-gradient-2.html 隐藏浏览器滚动条 https://blog.csdn. ...
- canvas 创建颜色渐变柱状图
最终结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...
- css实现内容渐变隐藏效果,手机网页版知乎内容隐藏效果的实现
看到一个需求,如下图,知乎手机网页版的一个视觉效果,对内容很长的部分有一个渐变的隐藏的效果,个人觉得这个设计还是很好的,符合手机大小的应用场景,没有一下子显示完全,可以很快的滑倒页面底部,一定程度上减 ...
- Vuforia图像追踪,动态创建的对象隐藏显示的坑
刚做的一个项目,使用Unity3D的Vuforia插件进行图像识别,其中有动态生成的游戏对象模型,地形模型放在ImageTarget下,作为ImageTarget的子物体. 动态生成的敌人则有Pref ...
- iOS开发之创建颜色渐变视图View
在iOS开发中有时需要自己自定义一个视图view的背景,而网上有人提出的在循环中不断alloc的方法设置其背景色渐变,会耗费很多内存和资源,极其不明智,而在CALayer中早就提供有图层渐变的类和相应 ...
- svg和css3创建环形渐变进度条
在负责的项目中,有一个环形渐变读取进度的效果的需求,于是在网上查阅相关资料整理一下.代码如下: <!DOCTYPE html> <html lang="en"&g ...
- Ionic2 渐变隐藏导航栏|标题栏
废话少说 直接上代码.... //导入需要用到的命名空间 ViewChild,Content import { Component, ViewChild } from '@angular/core'; ...
- IOS 创建渐变图层
代码如下 typedef enum { GradientLayerKindLeftRight = , GradientLayerKindUpDown, GradientLayerKindLBRT,// ...
- canvas 创建渐变图形
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
随机推荐
- SSH 超时断开连接解决办法
配置服务器端: vi /etc/ssh/sshd.conf ClientAliveInterval 120 #以秒为单位(可以改大些) ClientAliveCountMax 0 #发现客户端没有相应 ...
- obj-m
转自:http://blog.sina.com.cn/s/blog_693301190100sxoi.html obj-m (转帖) 目标定义是Kbuild Makefile的主要部分,也是核心部分. ...
- angular如何在一个网页中同时启动两个app?
AngularJS深入 这个系列真不错,是我想学的深入内容. http://syaning.com/2015/07/16/dive-into-angular-1/ 一般情况下,一个页面中只有一个应用, ...
- hdu 4022 STL
题意:给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人. /* HDU 4022 G++ 1296ms */ #include<stdio ...
- matlab练习程序(最小包围矩形)
又是计算几何,我感觉最近对计算几何上瘾了. 当然,工作上也会用一些,不过工作上一般直接调用boost的geometry库. 上次写过最小包围圆,这次是最小包围矩形,要比最小包围圆复杂些. 最小包围矩形 ...
- 【项目启动】 tomcat启动,项目无法启动,无法正常访问/项目可以启动,报错:java.lang.ClassNotFoundException: ContextLoaderListener
使用maven搭建项目(这个错误和是不是使用maven搭建项目没有关系),然后部署到tomcat中运行. 出现问题1: tomcat跑起来了,但是启动时间很短,没有报错,项目不能正常访问 项目启动时间 ...
- 调整linux的时钟
想把linux时钟调整的正常了. 网上找了找资料,找到了同步办法: http://blog.51yip.com/server/1474.html 即使用: sudo yum install ntp s ...
- 2016.6.17 计算机网络复习要点之PPP协议
点对点协议PPP是目前使用最广泛的数据链路层协议. 1.PPP协议的特点: **我们知道因特网用户通常需要连接到某个ISP才能接入到因特网,PPP协议就是用计算机和ISP进行通信时所使用的数据链路层协 ...
- Codeforces 498C Array and Operations(最大流)
题目是给一些数和<数对>的下标,然后进行操作:对某个<数对>中的两个数同时除以一个都能被它们整除且不等于1的数,要求的就是最多能进行多少次操作. 除数一定是素数,就是要决定某素 ...
- 2015ACM/ICPC亚洲区长春站 B hdu 5528 Count a * b
Count a * b Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...