QQ空间HD(6)-实现自定义的选项卡切换效果
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)-实现自定义的选项卡切换效果的更多相关文章
- 仿网易/QQ空间视频列表滚动连播炫酷效果
代码地址如下:http://www.demodashi.com/demo/11201.html 一.准备工作 AndroidStudio 开发环境 需要下载七牛的开源播放器SDK 本例子实现了仿网易/ ...
- 使用ViewPager+Fragment实现选项卡切换效果
实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果. 本程序用androi ...
- 使用jquery实现选项卡切换效果
几张简陋的框架效果图 页面加载时: 选项卡操作后: css样式: <style type="text/css"> *{margin:0px;padding:0px;} ...
- 用html+css+js实现选项卡切换效果
文章转载自:http://tongling.github.io/JSCards/ 用html+css+js实现选项卡切换效果 使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材 ...
- [前端] html+css+javascript 实现选项卡切换效果
用html+css+js实现选项卡切换效果使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材:房产: 275万购昌平邻铁三居 总价20万买一居 200万内购五环三居 140万安 ...
- JS实现选项卡切换效果
1.在网页制作过程中,我们经常会用到选项卡切换效果,它能够让我们的网页在交互和布局上都能得到提升 原理:在布局好选项卡的HTML结构后,我们可以看的出来,选项卡实际上是三个选项卡标头和三个对应的版块, ...
- 纯js实现网页tab选项卡切换效果
纯js实现网页tab选项卡切换效果 百度搜索 js 点击菜单项就可以切换内容的效果
- vue实现tab选项卡切换效果
tab选项卡切换效果: 通过点击事件传入参数,然后通过v-show来进行切换显示 <template> <div class="box"> <div ...
- vue实现选项卡切换效果
效果如下: 说明: 这里我使用的原理是利用vue中的v-show/显示隐藏指令,当为true的时候显示,为false的时候隐藏 1html代码: <head> <meta chars ...
随机推荐
- ActionBar详解
转: 一.ActionBar介绍 在Android 3.0中除了我们重点讲解的Fragment外,Action Bar也是一个非常重要的交互元素,Action Bar取代了传统的tittle bar和 ...
- [转]ASP.NET Core 之 Identity 入门(三)
本文转自:http://www.cnblogs.com/savorboard/p/aspnetcore-identity3.html 前言 在上一篇文章中,我们学习了 CookieAuthentica ...
- python爬虫学习 —— 总目录
开篇 作为一个C党,接触python之后学习了爬虫. 和AC算法题的快感类似,从网络上爬取各种数据也很有意思. 准备写一系列文章,整理一下学习历程,也给后来者提供一点便利. 我是目录 听说你叫爬虫 - ...
- POJ2186 Popular Cows [强连通分量|缩点]
Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 31241 Accepted: 12691 De ...
- IIS7.5使用web.config设置伪静态的二种方法(转)
近几天公司里开发的项目有几个运行在IIS7.5上,由于全站采用的是伪静态,因此从网上找到两两种方法来实现.这两种方法各有优势:第一种比较灵活,只要把文件拷到根目录下,即可直接显示所有伪静态页面(适用于 ...
- 快速部署tomcat项目的Shell脚本
为了做集群测试,在每台机器上装了3个tomcat,每次发布项目的时候都要反复敲一些命令,重启tomcat之前先检查tomcat进程有没有停掉,没有还要手动kill该进程. 发布次数多了,操作就比较繁琐 ...
- ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS
react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS npm install react-native-carousel --save git 地址Properties ...
- Word2Vec 使用总结
word2vec 是google 推出的做词嵌入(word embedding)的开源工具. 简单的说,它在给定的语料库上训练一个模型,然后会输出所有出现在语料库上的单词的向量表示,这个向量称为&qu ...
- android应用内存占用测试(每隔一秒打印procrank的信息)
1.内存占用 对于智能手机而言,内存大小是固定的:因此,如果单个app的内存占用越小,手机上可以安装运行的app就越多:或者说app的内存占用越小,在手机上运行就会越流畅.所以说,内存占用的大小,也是 ...
- Android 在非Activity的类中调用startActivityForResult
http://www.360doc.com/content/11/0720/10/7322578_134657348.shtml