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 ...
随机推荐
- dfs常见的配置文件中的value与description
照抄于网络: name value description dfs.namenode.logging.level info The logging level for dfs namenode. Ot ...
- PHPCMS V9静态化HTML生成设置及URL规则优化
先讲讲Phpcms V9在后台怎么设置生成静态化HTML,之后再讲解怎么自定义URL规则,进行URL地址优化.在这一篇中,伪静态就不涉及了,大家可以移步到Phpcms V9全站伪静态设置方法. 一.静 ...
- POJ 2299 逆序对
Crossings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description I ...
- linux下用top命令查看cpu利用率超过100%
今天跑了一个非常耗时的批量插入操作..通过top命令查看cpu以及内存的使用的时候,cpu的时候查过了120%..以前没注意..通过在top的情况下按大键盘的1,查看的cpu的核数为4核. 通过网上查 ...
- MATLAB学习笔记(八)——MATLAB数值积分与微分
(一)数值积分 一.数值积分的MATLAB实现方法: 1.变步长辛普生法(quad)法: (1)调用格式: [I,n]=quad('fname',a,b,tol,trace); fname是被积函数: ...
- android 自定义弹出框AlertDialog ,很炫的哦
于是就小小的模仿了下自己写了这个这样的效果,主要代码如下:dlg = new AlertDialog.Builder(context).create();dlg.show();dlg.getWin ...
- include、include_once与require、require_once区别
include与require的区别 include在引入不存文件时产生一个警告且脚本还会继续执行,而require则会导致一个致命性错误且脚本停止执行. <?php include 'no.p ...
- 2016.7.9 计算机网络复习要点第四章之网际控制报文协议ICMP
1.ICMP允许主机或路由器报告差错情况和提交有关异常情况的报告:为了更有效地转发IP数据报和提高交付成功的机会: 2.ICMP不是高层协议,因为ICMP报文是装在IP数据报中的,作为其中数据部分,所 ...
- DelPhi学习网站
http://www.2ccc.com/downloads.asp?subcatalogid=101&pageid=14 http://www.2ccc.com/ http://www.xue ...
- quick 截屏
MainScene local MainScene = class("MainScene", function() return display.newScene("Ma ...