自定义弧形的 tabBar
//
// TabBarViewController.h
// LittleLoveLive
//
// Created by YJ
//
// TabBarViewController.m
// LittleLoveLive
//
// Created by YJ on 16/7/16.
// Copyright © 2016年 YJ. All rights reserved.
// #import "TabBarViewController.h"
#import "RootNavigationController.h"
#import "HomeViewController.h"
#import "LiveViewController.h"
#import "MeViewController.h"
@interface TabBarViewController () @end @implementation TabBarViewController - (void)viewDidLoad {
[super viewDidLoad]; [self setupTheLine];
[self initialControllers]; } //初始化子控制器
-(void)initialControllers { [self setupController:[[HomeViewController alloc]init] image:@"icon_home_normal.png" selectedImage:@"icon_home_pressed.png" title:nil];
[self setupController:[[LiveViewController alloc]init] image:@"icon_live_normal.png" selectedImage:@"icon_live_pressed.png" title:nil];
[self setupController:[[MeViewController alloc] init] image:@"icon_me_normal.png" selectedImage:@"icon_me_pressed.png" title:nil]; } //设置控制器
-(void)setupController:(UIViewController *)childVc image:(NSString *)image selectedImage:(NSString *)selectedImage title:(NSString *)title { //标题
childVc.title = title;
//childVc.view.backgroundColor = RGBACOLOR(239.0f, 239.0f, 244.0f, 1.0f); //tabBarItem图片
childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; //tabBarItem字体的设置
//正常状态
NSMutableDictionary *normalText = [NSMutableDictionary dictionary];
normalText[NSForegroundColorAttributeName] = [UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:1.0];
[childVc.tabBarItem setTitleTextAttributes:normalText forState:UIControlStateNormal]; //选中状态
NSMutableDictionary *selectedText = [NSMutableDictionary dictionary];
selectedText[NSForegroundColorAttributeName] = [UIColor blackColor];
[childVc.tabBarItem setTitleTextAttributes:selectedText forState:UIControlStateSelected]; RootNavigationController *nav = [[RootNavigationController alloc]initWithRootViewController:childVc];
[self addChildViewController:nav]; } //设置分割线
-(void)setupTheLine { UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(, -, self.tabBar.frame.size.width, self.tabBar.frame.size.height)];
[imageView setImage:[UIImage imageNamed:@"bg_tabbar"]];
[imageView setContentMode:UIViewContentModeCenter];
[self.tabBar insertSubview:imageView atIndex:];
//覆盖原生Tabbar的上横线
[[UITabBar appearance] setShadowImage:[self createImageWithColor:[UIColor clearColor]]];
[[UITabBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor clearColor]]];
//设置TintColor
// UITabBar.appearance.tintColor = [UIColor orangeColor]; } -(UIImage*) createImageWithColor:(UIColor*) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
} //设置中间按钮不受TintColor影响
- (void)awakeFromNib {
[super awakeFromNib];
NSArray *items = self.tabBar.items;
//设置第几个 tabBar不受影响
UITabBarItem *btnAdd = items[];
btnAdd.image = [btnAdd.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
btnAdd.selectedImage = [btnAdd.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
on 16/7/16.
// Copyright © 2016年 YJ. All rights reserved.
// #import <UIKit/UIKit.h> @interface TabBarViewController : UITabBarController @end
自定义弧形的 tabBar的更多相关文章
- 自定义react-navigation的TabBar
在某些情况下,默认的react-navigation的tab bar无法满足开发者的要求.这个时候就需要自定义一个tab bar了.本文就基于react-navigtion v2来演示如何实现一个自定 ...
- iOS 自定义UITabBarController的tabBar
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDeleg ...
- iOS 自定义滑动切换TabBar
貌似经常会用到,自己整理收藏起来,方便日后查找备用. 效果如图: 由于制作gif,调整了属性,所以看起来的效果不好.如果用默认配置,生成的gif会很大. 制作gif: 1.使用QuickTimePla ...
- Nuxt/Vue自定义导航栏Topbar+标签栏Tabbar组件
基于Vue.js实现自定义Topbar+Tabbar组件|仿咸鱼底部凸起导航 最近一直在倒腾Nuxt项目,由于Nuxt.js是基于Vue.js的服务端渲染框架,只要是会vue,基本能很快上手了. 一般 ...
- 自定义UITabBar的两种方式
开发中,经常会遇到各种各样的奇葩设计要求,因为apple提供的UITabBar样式单一,只是简单的"图片+文字"样式,高度49又不可以改变.自定义UITabBar成为了唯一的出路. ...
- swift-UINavigationController纯代码自定义导航控制器及底部工具栏的使用
step1:自定义一个类 NTViewController,该类继承UITabBarController: // // NTViewController.swift // Housekeeper / ...
- svelte组件:Svelte3自定义Navbar+Tabbr组件|svelte自定义插件
基于Svelte3自定义组件Navbar+Tabbar沉浸式导航条|底部凸起菜单栏 Svelte 一种全新的构建用户界面的框架.当下热门的 Vue 和 React 在浏览器中需要做大量的工作,而 Sv ...
- github代码集合(转载)
菜鸟新闻项目课程源码 https://github.com/yxs666/cniao5-news SwipeRefreshLayout + RecyclerView 下拉刷新和上拉加载更多 http ...
- iOS各种开源类库
KissXml——xml解析库 相关教程:http://www.iteye.com/topic/625849 http://sencho.blog.163.com/blog/static/830562 ...
随机推荐
- 对ArrayList 进行深拷贝
ArrayList arr = new ArrayList(); arr.Add()); arr.Add()); arr.Add()); ArrayList arr2 = new ArrayList( ...
- windwos iis 7.5 使用html 报405错误
今天遇到了这个问题,网上搜一下基本上都是下面的答案: <form> 没有指定action的话就是文件自身了. .html本身是不可执行的,如果要修改的话,在IIS中站点属性- 主目录 - ...
- jquery validate easyui tooltip
jquery validate.js onfocusin: function (element, event) { this.lastActive = element; // hide error l ...
- 第二百四十七天 how can I 坚持
今天去了趟北海公园,看到地铁宣传图片挺好看的,实景也倒是不错,环境好了,哪都好,今天是蓝天白云啊. 回来的路上看了,扎克伯格对质疑的回应.哎.改变世界在硅谷是行动,而不是口号.change the w ...
- FrameWork 建模时查询项的usage
§ Identifier:代表被用于分组或汇总与其相关的Fact数据的列.也代表一个索引列.还代表日期或时间列.§ Fact:代表一个包含数值数据可被分组或汇总的列,例如,产品成本.§ Attribu ...
- HDU 5724 Chess (sg函数)
Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5724 Description Alice and Bob are playing a s ...
- Configure the handler mapping priority in Spring MVC
Often times, you may mix use of multiple handler mappings strategy in Spring MVC development. For ex ...
- Java IO (4) - Writer
Java IO (4) - Writer 前言 JavaIO一共包括两种,一种是stream,一种是reader/writer,每种又包括in/out,所以一共是四种包.Java 流在处理上分为字符流 ...
- poj 1679 http://poj.org/problem?id=1679
http://poj.org/problem?id=1679 The Unique MST Time Limit: 1000MS Memory Limit: 10000K Total Submis ...
- 网络复习之TCP
可靠传输的工作原理 1 停止等待协议 每发送完一个分组,就停止发送,等待对方确认.出现差错,超时重传. 1.1 暂时保留已发送的分组的副本 1.2 分组和确认分组必须进行编号 ...