#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的更多相关文章

  1. 新浪微博客户端(8)-添加按钮到TabBar

    在tabBar的中部添加一个发送微博的按钮. DJTabBar.h #import <UIKit/UIKit.h> @class DJTabBar; @protocol DJTabBarD ...

  2. jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动

    jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动 http://www.17sucai.com/pins/demoshow/382

  3. android自定义文本框,后面带清空按钮

    android常见的带清空按钮的文本框,获得焦点时如果有内容则显示,否则不显示 package com.qc.health.weight; import com.qc.health.R; import ...

  4. WPF 带清除按钮的文字框SearchTextBox

    原文:WPF 带清除按钮的文字框SearchTextBox 基于TextBox的带清除按钮的搜索框 样式部分: <!--带清除按钮文字框--> <Style TargetType=& ...

  5. 带清空按钮TextBox的实现(WPF)

    本博文针对人群:WPF新手.博文内容:通过Style制定包含清空Button的TextBox样式模板,通过在Style中引入自定义类的附加属性完成对TextBox的内容清空. <span sty ...

  6. jQuery仿3D旋转木马效果插件(带索引按钮)

    项目中需要用到旋转木马效果,但是我在网上找的插件,基本都是不带按钮或者只是带前后按钮的,而项目要求的是带索引按钮,也就是说有3张图片轮播,对应的要有3个小按钮,点击按钮,对应的图片位于中间位置.于是就 ...

  7. 模拟邮箱输入邮箱地址、收藏标签。input框输入内容后回车,内容显示成小方块并带删除按钮。

    模拟邮箱输入邮箱地址.收藏标签: 文本框输入文字后按回车键或者分号键,输入框中的文字变成小块并带删除按钮和操作. 页面代码: <!DOCTYPE html> <%@ page lan ...

  8. iOS 开源一个高度可定制支持各种动画效果,支持单击双击,小红点,支持自定义不规则按钮的tabbar

    TYTabbarAnimationDemo 业务需求导致需要做一个tabbar,里面的按钮点击带有动画效果,tabbar中间的按钮凸出,凸出部分可以点击,支持badge 小红点等,为此封装了一个高度可 ...

  9. 35.Android之带删除按钮EditText学习

    今天实现Android里自定义带删除功能的EditText,效果如下: 当输入内容时,EditText变为带有一个删除功能按钮的编辑框,如图: 实现代码很简单,直接上代码, 布局文件xml: < ...

随机推荐

  1. FineReport中如何用JavaScript自定义地图标签

    在日常使用地图过程中,通常会遇到地图标签,提示点等显示不满足我们的需求,需要进行JavaScript代码编写. 例如:在使用地图过程中,会发现很多地名显示的位置偏离.这时候就需要使用JavaScrip ...

  2. PHP自定义函数&数组

    <?php//生成随机数 和 时间函数//echo rand();//echo "<br>";//echo rand(0,10);//echo time();// ...

  3. 一步一步pwn路由器之radare2使用实战

    前言 本文由 本人 首发于 先知安全技术社区: https://xianzhi.aliyun.com/forum/user/5274 前文讲了一些 radare2 的特性相关的操作方法.本文以一个 c ...

  4. java 内存分析之方法返回值及匿名对象一

    package Demo; public class Point { private double x, y, z; public Point(double _x, double _y, double ...

  5. sql in interview for a job

    1.mysql下建表及插入数据 /* Navicat MySQL Data Transfer Source Server : mysql Source Server Version : 50640 S ...

  6. MySQL存储引擎之Spider内核深度解析

      作者介绍 朱阅岸,中国人民大学博士,现供职于腾讯云数据库团队.研究方向主要为数据库系统理论与实现.新硬件平台下的数据库系统以及TP+AP型混合系统. Spider是为MySQL/MariaDB开发 ...

  7. 转:winform 安装包(很详细)

    winform安装项目.安装包的制作.部署 ① 1,解决方案—添加—新建项目—其他项目类型—安装和部署—安装项目,输入名称Setup,点“确定” 2,添加主输出:单击左侧“应用程序文件夹”,右侧右键— ...

  8. 铁乐学python_day20_面向对象编程2

    面向对象的组合用法 软件重用的重要方式除了继承之外还有另外一种方式,即:组合 组合指的是,在一个类中以另外一个类的对象作为数据属性,称为类的组合. 例:人狗大战,人类绑定上武器来对狗进行攻击: # 定 ...

  9. marquee 标签的鼠标放上去滚动效果 鼠标离开继续滚动

    效果很实用,可以轻松的实现鼠标放上去停止滚动.鼠标离开继续滚动的效果.下面是具体的用法(特别注意onMouseOver和onMouseOut是需要同时写进去才会出现比较好的效果):onMouseOut ...

  10. November 27th 2016 Week 48th Sunday

    It is never too late to be what you might have been. 勇敢做自己,永远不嫌迟. What I might have been? Experienci ...