底部带突出按钮的tabbar
#import "ViewController.h" #import "FirstViewController.h"
#import "SecondViewController.h"
#import "MiddleViewController.h"
#import "ThirdViewController.h"
#import "FourViewController.h" @interface ViewController ()
{
UIImageView *imageView;
NSArray *imageArray;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; imageArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"startImg0"],[UIImage imageNamed:@"startImg1"],[UIImage imageNamed:@"startImg2"],[UIImage imageNamed:@"startImg3"],[UIImage imageNamed:@"startImg4"],[UIImage imageNamed:@"startImg5"],[UIImage imageNamed:@"startImg6"], nil]; FirstViewController *first = [[FirstViewController alloc] init];
first.tabBarItem.title = @"首页";
first.tabBarItem.image = [UIImage imageNamed:@"tabbar_company_home"];
[first.tabBarItem setSelectedImage:[UIImage imageNamed:@"tabbar_company_home_select"]]; SecondViewController *second = [[SecondViewController alloc] init];
second.tabBarItem.title = @"动态";
second.tabBarItem.image = [UIImage imageNamed:@"tabbar_dynamic"];
[second.tabBarItem setSelectedImage:[UIImage imageNamed:@"tabbar_dynamic_selected"]]; MiddleViewController *middle = [[MiddleViewController alloc] init];
[self addCenterButtonWithImage:[UIImage imageNamed:@"middleImage"] highlightImage:nil]; ThirdViewController *third = [[ThirdViewController alloc] init];
third.tabBarItem.title = @"广场";
third.tabBarItem.image = [UIImage imageNamed:@"tabbar_position_oringin"];
[third.tabBarItem setSelectedImage:[UIImage imageNamed:@"tabbar_position_selected"]]; FourViewController *four = [[FourViewController alloc] init];
four.tabBarItem.title = @"我的";
four.tabBarItem.image = [UIImage imageNamed:@"tabbar_mine_oringin"];
[four.tabBarItem setSelectedImage:[UIImage imageNamed:@"tabbar_mine_selected"]]; self.viewControllers = @[first,second,middle,third,four];
} //添加中间按钮
- (void)addCenterButtonWithImage:(UIImage *)buttonImage highlightImage:(UIImage *)highlightImage
{
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button setBackgroundImage:highlightImage forState:UIControlStateHighlighted]; CGFloat heightDifference = buttonImage.size.height - self.tabBar.frame.size.height;
if (heightDifference < )
button.center = self.tabBar.center;
else
{
CGPoint center = self.tabBar.center;
center.y = center.y - heightDifference/2.0;
button.center = center;
} [self.view addSubview:button];
} - (void)buttonClick
{
NSLog(@"点击中间按钮"); imageView = [[UIImageView alloc] initWithFrame:CGRectMake(, , self.view.bounds.size.width, self.view.bounds.size.height)];
imageView.animationImages = imageArray;
imageView.animationRepeatCount = ;
imageView.animationDuration = 1.0f;
[imageView startAnimating];
[self.view addSubview:imageView];
}
底部带突出按钮的tabbar的更多相关文章
- 新浪微博客户端(8)-添加按钮到TabBar
在tabBar的中部添加一个发送微博的按钮. DJTabBar.h #import <UIKit/UIKit.h> @class DJTabBar; @protocol DJTabBarD ...
- jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动
jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动 http://www.17sucai.com/pins/demoshow/382
- android自定义文本框,后面带清空按钮
android常见的带清空按钮的文本框,获得焦点时如果有内容则显示,否则不显示 package com.qc.health.weight; import com.qc.health.R; import ...
- WPF 带清除按钮的文字框SearchTextBox
原文:WPF 带清除按钮的文字框SearchTextBox 基于TextBox的带清除按钮的搜索框 样式部分: <!--带清除按钮文字框--> <Style TargetType=& ...
- 带清空按钮TextBox的实现(WPF)
本博文针对人群:WPF新手.博文内容:通过Style制定包含清空Button的TextBox样式模板,通过在Style中引入自定义类的附加属性完成对TextBox的内容清空. <span sty ...
- jQuery仿3D旋转木马效果插件(带索引按钮)
项目中需要用到旋转木马效果,但是我在网上找的插件,基本都是不带按钮或者只是带前后按钮的,而项目要求的是带索引按钮,也就是说有3张图片轮播,对应的要有3个小按钮,点击按钮,对应的图片位于中间位置.于是就 ...
- 模拟邮箱输入邮箱地址、收藏标签。input框输入内容后回车,内容显示成小方块并带删除按钮。
模拟邮箱输入邮箱地址.收藏标签: 文本框输入文字后按回车键或者分号键,输入框中的文字变成小块并带删除按钮和操作. 页面代码: <!DOCTYPE html> <%@ page lan ...
- iOS 开源一个高度可定制支持各种动画效果,支持单击双击,小红点,支持自定义不规则按钮的tabbar
TYTabbarAnimationDemo 业务需求导致需要做一个tabbar,里面的按钮点击带有动画效果,tabbar中间的按钮凸出,凸出部分可以点击,支持badge 小红点等,为此封装了一个高度可 ...
- 35.Android之带删除按钮EditText学习
今天实现Android里自定义带删除功能的EditText,效果如下: 当输入内容时,EditText变为带有一个删除功能按钮的编辑框,如图: 实现代码很简单,直接上代码, 布局文件xml: < ...
随机推荐
- Global Average Pooling Layers for Object Localization
For image classification tasks, a common choice for convolutional neural network (CNN) architecture ...
- maven打包 springBoot 工程时,默认识别resources目录,习惯使用 resource 目录的需要手动指定静态资源目录
最近项目开发,发现springBoot项目在使用maven打包时,我们静态资源文件都放在resource目录下面,大致如下: 在使用maven打包时,发现静态资源没有打进去.原来springBoot默 ...
- ES6中的import与export对class操作相关用法举例
两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...
- 附加到SQL2012的数据库就不能再附加到低于SQL2012的数据库版本
附加到SQL2012的数据库就不能再附加到低于SQL2012的数据库版本 昨天我只是将数据库附加到SQL2012,然后各个数据库都做了收缩事务日志的操作 兼容级别这些都没有改 再附加回SQL2005的 ...
- 梯度下降法实现最简单线性回归问题python实现
梯度下降法是非常常见的优化方法,在神经网络的深度学习中更是必会方法,但是直接从深度学习去实现,会比较复杂.本文试图使用梯度下降来优化最简单的LSR线性回归问题,作为进一步学习的基础. import n ...
- 从本机构建Windows应用程序虚拟机映像
下图描述了总体的虚拟机映像的VHD生成,上传以及发布到 Azure 镜像市场的全过程: 具体步骤如下: 在本地计算机(Windows平台)上安装Hyper-V,并安装您所需要的虚拟机操作系统 在此操作 ...
- 解决python2和python3的pip冲突
最近突然出现了一种情况当电脑上同时安装python2和python3的时候会导致我的pip冲突 . 最终经过我的发现是因为其环境没有配置好 还有就是没有找到精准的包导致的 1.下载python2.7, ...
- wxpython 窗口排版- proportion/flag/border参数说明
新学习wxpython,一直纠结于窗口控件的排版,经过几天的查资料.试验,总结如下. 1.需求实例 来个实例,窗口有3行控件 第一行是文本提示(大小不变,文字左对齐,控件居左). 第二行依次为文本提示 ...
- 铁乐学python27_模块学习2
大部份内容摘自博客http://www.cnblogs.com/Eva-J/ collections模块 在内置数据类型(dict.list.set.tuple)的基础上, collections模块 ...
- 人工智能——搜索(1)回溯策略【N皇后问题】
这学期学<人工智能>(马少平,朱小燕 编著)这本书,里面很多算法听老师讲都听不懂,就想试试写一下看看能不能写出来,就从最简单的回溯策略开始吧. 源码 题目描述 在一个n*n的国际象棋棋盘上 ...