DJTabbarButton.m

#import "DJTabbarButton.h"

@implementation DJTabbarButton

- (instancetype)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {
[self setBackgroundImage:[UIImage imageNamed:@"tabbar_separate_selected_bg"] forState:UIControlStateDisabled];
self.imageView.contentMode = UIViewContentModeCenter; /* 设置当按钮不可用或高亮状态时不要修改图片 */
self.adjustsImageWhenDisabled = NO;
self.adjustsImageWhenHighlighted = NO;
// self.backgroundColor = [UIColor greenColor];
}
return self;
} - (void)layoutSubviews { [super layoutSubviews]; if (DJLandscape) { // 横屏 /* imageView */
self.imageView.x = ;
self.imageView.y = ;
self.imageView.width = self.width * 0.4;
self.imageView.height = self.height; /* titleLabel */
self.titleLabel.hidden = NO;
self.titleLabel.x = self.imageView.width;
self.titleLabel.y = ;
self.titleLabel.width = self.width - self.imageView.width;
self.titleLabel.height = self.height; } else { // 竖屏 /* imageView */
self.imageView.frame = self.bounds;
/* titleLabel */
self.titleLabel.hidden = YES;
}
} /* 设置按钮无高亮状态 */
- (void)setHighlighted:(BOOL)highlighted { } @end

DJHomeViewController.m

// 添加子控制器
- (void)setupChildViewControllers { for (int i = ; i < ; i++) {
UIViewController *childVC = [[UIViewController alloc] init];
childVC.view.backgroundColor = DJRandomColor;
[self addChildViewController:childVC];
}
} - (void)replaceCurrentShowingController:(DJTabBarIndex)index { // 将当前显示的子控制器的View从界面上移除
[self.showingChildVc.view removeFromSuperview];
UIViewController *newShowingVc;
switch (index) {
case DJTabBarIndexAllStatus: // 全部动态
newShowingVc = self.childViewControllers[];
break;
case DJTabBarIndexWithMe: // 与我相关
newShowingVc = self.childViewControllers[];
break;
case DJTabBarIndexPhotoWall: // 照片樯
newShowingVc = self.childViewControllers[];
break;
case DJTabBarIndexPhotoFrame: // 电子相框
newShowingVc = self.childViewControllers[];
break;
case DJTabBarIndexFriend: // 好友
newShowingVc = self.childViewControllers[];
break;
case DJTabBarIndexMore: // 更多
newShowingVc = self.childViewControllers[];
break;
} newShowingVc.view.x = self.menuView.width;
newShowingVc.view.y = ;
newShowingVc.view.width = self.view.width - self.menuView.width;
newShowingVc.view.height = self.view.height;
[self.view addSubview:newShowingVc.view];
self.showingChildVc = newShowingVc; } - (void)updateSubViewFrameInLandscape { /* menuView */
self.menuView.width = DJMenuViewLW;
self.menuView.height = DJScreenLH;
self.menuView.x = ;
self.menuView.y = ; /* showingChildVc */
self.showingChildVc.view.x = self.menuView.width;
self.showingChildVc.view.y = ;
self.showingChildVc.view.width = DJScreenLW - self.menuView.width;
self.showingChildVc.view.height = DJScreenLH; } - (void)updateSubViewsViewFrameInPortrait { /* menuView */
self.menuView.width = DJMenuViewPW;
self.menuView.height = DJScrrenPH;
self.menuView.x = ;
self.menuView.y = ; /* showingChildVc */
self.showingChildVc.view.x = self.menuView.width;
self.showingChildVc.view.y = ;
self.showingChildVc.view.width = DJScreenPW - self.menuView.width;
self.showingChildVc.view.height = DJScrrenPH; }
// 当屏幕方向将会发生改变时调用此方法
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { // 横屏
[self updateSubViewFrameInLandscape];
} else { // 竖屏
[self updateSubViewsViewFrameInPortrait];
} // 设置当前子控制器的View不拉伸
self.showingChildVc.view.autoresizingMask = UIViewAutoresizingNone; }

最终效果:

QQ空间HD(6)-实现自定义的选项卡切换效果的更多相关文章

  1. 仿网易/QQ空间视频列表滚动连播炫酷效果

    代码地址如下:http://www.demodashi.com/demo/11201.html 一.准备工作 AndroidStudio 开发环境 需要下载七牛的开源播放器SDK 本例子实现了仿网易/ ...

  2. 使用ViewPager+Fragment实现选项卡切换效果

    实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果. 本程序用androi ...

  3. 使用jquery实现选项卡切换效果

    几张简陋的框架效果图 页面加载时: 选项卡操作后: css样式: <style type="text/css"> *{margin:0px;padding:0px;} ...

  4. 用html+css+js实现选项卡切换效果

    文章转载自:http://tongling.github.io/JSCards/ 用html+css+js实现选项卡切换效果 使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材 ...

  5. [前端] html+css+javascript 实现选项卡切换效果

    用html+css+js实现选项卡切换效果使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材:房产: 275万购昌平邻铁三居 总价20万买一居 200万内购五环三居 140万安 ...

  6. JS实现选项卡切换效果

    1.在网页制作过程中,我们经常会用到选项卡切换效果,它能够让我们的网页在交互和布局上都能得到提升 原理:在布局好选项卡的HTML结构后,我们可以看的出来,选项卡实际上是三个选项卡标头和三个对应的版块, ...

  7. 纯js实现网页tab选项卡切换效果

    纯js实现网页tab选项卡切换效果 百度搜索     js 点击菜单项就可以切换内容的效果

  8. vue实现tab选项卡切换效果

    tab选项卡切换效果: 通过点击事件传入参数,然后通过v-show来进行切换显示 <template> <div class="box"> <div ...

  9. vue实现选项卡切换效果

    效果如下: 说明: 这里我使用的原理是利用vue中的v-show/显示隐藏指令,当为true的时候显示,为false的时候隐藏 1html代码: <head> <meta chars ...

随机推荐

  1. 将Apache手动安装成Windows的服务

    将Apache手动安装成Windows的服务 可以选择在安装Apache时自动将其安装为一个服务.如果选择"for all users",那么Apache将会被安装为服务. 如果选 ...

  2. HashMap实现原理分析(转)

    文章转自:http://blog.csdn.net/vking_wang/article/details/14166593 1. HashMap的数据结构 数据结构中有数组和链表来实现对数据的存储,但 ...

  3. 在运行Hibernate Hello World程序的时候,抛如下错误: view plain Exception in thread "main" org.hibernate.exception.LockAcquisitionException 解决方法

    在运行Hibernate Hello World程序的时候,抛如下错误: Exception in thread "main" org.hibernate.exception.Lo ...

  4. POJ2425 A Chess Game[博弈论 SG函数]

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Desc ...

  5. list去从复

    for(int i=0;i<queryList.size();i++){//去重             String time =queryList.get(i);             i ...

  6. [No000089]String的(补空位)左对齐,(补空位)右对齐

    using System; namespace Chinese中文排序Sort { internal class Program { /// <summary> /// 取子字符串 /// ...

  7. [技术分享] centos如何挂载Windows共享文件

    http://www.iyunv.com/thread-294209-1-1.html 最为linux的初学者,自我感觉都会使用Windows中的文件.在Windows与linux之间互传文件是一个问 ...

  8. [LeetCode] Implement Trie (Prefix Tree)

    Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs ar ...

  9. 测试工作的疑难杂症bugs

    一. 平台:安卓app 代码:重写onresume事件时,没有重新获取sessionId导致记录一下bug重现过程:1.登陆2.退出用户(不退出app)3.重新登录4.home键或者息屏5.再进入ap ...

  10. Ceph RGW 的 OSPF负载均衡 + quagga的配置

      随着开源技术的发展,以及商业设备价格的不断攀升.大公司总是希望能使用开源的方案来替换过去使用的商业设备.比如之前大家用的很多的F5和A10,现在已经在逐步被LVS替换.传统的单个lvs的性能是比不 ...