UITabBarController自定义二之xib

  • 新建一个xib文件

  • 在UITabBarController的子类方法viewDidLoad方法中加载xib

1.-(void)viewDidLoad{
2. [super viewDidLoad];
3. self.tabBar.hidden = YES;
4.
5. _customTabBar = [[[NSBundle mainBundle] loadNibNamed:@"tabBar" owner:self options:nil] firstObject];
6.
7. CGRect frame = _customTabBar.frame;
8. frame.origin.y = self.view.bounds.size.height - frame.size.height;
9. _customTabBar.frame = frame;
10. [self.view addSubview:_customTabBar];
11.
12. for (UIView *view in _customTabBar.subviews) {
13. if ([view isKindOfClass:[UIButton class]]) {
14. UIButton *btn = (UIButton *)view;
15. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
16. }
17. }
18.}
19.
20.-(void)btnClick:(UIButton *)sender{
21.
22. for (UIView *view in _customTabBar.subviews) {
23. if ([view isKindOfClass:[UIButton class]]) {
24. UIButton *btn = (UIButton *)view;
25. btn.selected = NO;
26. }
27. }
28. self.selectedIndex = sender.tag - 200;
29. sender.selected = YES;
30.
31.
32.}
33.
  • 效果
 

UITabBarController自定义二之xib的更多相关文章

  1. MapReduce自定义二次排序流程

    每一条记录开始是进入到map函数进行处理,处理完了之后立马就入自定义分区函数中对其进行分区,当所有输入数据经过map函数和分区函数处理完之后,就调用自定义二次排序函数对其进行排序. MapReduce ...

  2. UITabBarController自定义一

    UITabBarController自定义一 首先在Appdelegate.m文件中将UITabBarController的子类设置为rootViewController,并设置其viewContro ...

  3. Hadoop学习之自定义二次排序

    一.概述    MapReduce框架对处理结果的输出会根据key值进行默认的排序,这个默认排序可以满足一部分需求,但是也是十分有限的.在我们实际的需求当中,往 往有要对reduce输出结果进行二次排 ...

  4. Android生成自定义二维码

    前面说过两种二维码扫描方式,现在说如何生成自定义酷炫二维码.二维码生成需要使用Google开源库Zxing,Zxing的项目地址:https://github.com/ZBar/ZBar,我们只需要里 ...

  5. C 二维数组,以及自定义二维数组

    C 二维数组,以及自定义二维数组 我们通常情况下是这样定义一个二维数组的: int a[10][15]; 我们分别查看一下a,a[0],*a 都是一样的值吧 我们可以这么理解: a是一个数组的数组 a ...

  6. 自定义cell(xib)中button点击事件不能响应的情况

    遇到这种问题真的好尴尬,之前从来没有遇到过,以为手到擒来,未曾料到还会遇到问题! 好多年没有找到尴尬的感觉,现在找到了,真的很尴尬 !  *o* 1.首先使用场景: 原本没打算用xib,后来为了快速, ...

  7. UITabBarController 笔记(二) ViewController中加UITabBarController

    新建一个简单视图iOS工程,在ViewController的viewDidLoad中代码如下 - (void)viewDidLoad { [super viewDidLoad]; // Do any ...

  8. 自定义UIViewController与xib文件关系深入分析

    6月14日 上海 OSC 源创会开始报名啦,有很多机械键盘送哦!!! 用xcode模板向工程加入UIViewController sub class的时候,如果选中了with xib for inte ...

  9. iOS--控制器加载自定义view的xib

    我们在项目中,经常需要使用到自定义的view,而xib布局显得更为简洁,那么如何加载一个自定义的xib呢,网上的方法也很多很多,就是因为太多了,我经常会弄混,所以总结其中一个使用,如果以后使用到其他的 ...

随机推荐

  1. cf E. George and Cards

    http://codeforces.com/contest/387/problem/E 题意:给你n个数,然后在输入k个数,这k个数都在n个数中出现,进行每一次操作就是在n个数中选择长度为w的连续序列 ...

  2. [原创]leet code - path sum

    ;            ;                ;                            }        }        ;            }};

  3. centos 6.5 安装weixin

    下载cpanm wget http://xrl.us/cpanm --no-check-certificate -O /sbin/cpanm && chmod +x /sbin/cpa ...

  4. RC隔离 更新where条件列 没有索引的情况

    CREATE TABLE `test100` ( `sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增编号', `phoneNo` int(11) , `c ...

  5. mysql 安装1

    Linux 安装mysql.tar.gz包(2012-09-28 19:25:06) 标签: it 分类: linux学习编 我用的mysql的版本的是:mysql--linux-i686-icc-g ...

  6. 【HDOJ】2428 Stars

    先排序后二分. #include <iostream> #include <cstdio> #include <cstring> #include <algo ...

  7. C++ Primer 随笔 Chapter 9 顺序容器

     参考:http://www.cnblogs.com/kurtwang/archive/2010/08/19/1802912.html 1..顺序容器:vector(快速随机访问):list(快速插入 ...

  8. 字符串[未AC](后缀自动机):HEOI 2016 str

    超级恶心,先后用set维护right,再用主席树维护,全部超时,本地测是AC的.放心,BZOJ上还是1S限制,貌似只有常数优化到一定境界的人才能AC吧. 总之我是精神胜利了哦耶QAQ #include ...

  9. Contains Duplicate II ——LeetCode

    Given an array of integers and an integer k, find out whether there there are two distinct indices i ...

  10. 动态规划——E (LIS())最长上升子序列

    E - LIS Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...