设置UITabBar自己为代理实现页面的动画转场(MS)
来源:互联网 发布:node 绑定域名 编辑:程序博客网 时间:2024/06/05 20:29
#import "ViewController.h"
@interfaceViewController ()
{
UIView * _view0;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// 设置屏幕背景色
self.view.backgroundColor = [UIColorwhiteColor];
// 加载view
[self_loadViews];
// 加载tabbar
[self_loadTabBar];
}
- (void)_loadTabBar{
// 初始化UITabBar
UITabBar * tabBar = [[UITabBaralloc]initWithFrame:CGRectMake(0,self.view.frame.size.height -49, self.view.frame.size.width,49)];
tabBar.delegate =self;// 设置自己为代理
// 初始化barItem
UIImage * imgForItem1 = [UIImageimageNamed:@"icon_cinema"];
UIImage * imgForItem2 = [[UIImageimageNamed:@"icon_cinema@2x"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem * item1 = [[UITabBarItemalloc]initWithTitle:@"Cinema"image:imgForItem1 selectedImage:imgForItem2];
item1.tag =100;
UITabBarItem * item2 = [[UITabBarItemalloc]initWithTitle:@"2"image:[UIImageimageNamed:@"more_select_setting"]tag:101];
UITabBarItem * item3 = [[UITabBarItemalloc]initWithTitle:@"3"image:[UIImageimageNamed:@"movie_cinema"]tag:102];
UITabBarItem * item4 = [[UITabBarItemalloc]initWithTitle:@"Movie"image:[UIImageimageNamed:@"msg_new"]tag:103];
UIImage * img1ForItem5 = [UIImageimageNamed:@"start_top250"];// 未设置保持原色
UIImage * img2ForItem5 = [[UIImageimageNamed:@"start_top250"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//保持原色,在图片初始化时实现
UITabBarItem * item5 = [[UITabBarItemalloc]initWithTitle:@"9"image:img1ForItem5 selectedImage:img2ForItem5];
// NSBackgroundColorAttributeName
// 用字典设置item5的字体颜色
NSDictionary * dict =@{NSFontAttributeName:[UIFontsystemFontOfSize:18],NSForegroundColorAttributeName:[UIColoryellowColor]};
// 设置高亮状态的字体及颜色
[item5 setTitleTextAttributes:dictforState:UIControlStateHighlighted];
NSArray * array = @[item1,item2,item3,item4,item5];
tabBar.items = array;
tabBar.selectedItem = array[0];//默认选中
[self.viewaddSubview:tabBar];
}
- (void)_loadViews{
UIView * view1 = [[UIViewalloc ]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height-49)];
view1.backgroundColor = [UIColorredColor];
view1.tag =200;
UIView * view2 = [[UIViewalloc ]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height -49)];
view2.backgroundColor = [UIColoryellowColor];
view2.tag =201;
UIView * view3 = [[UIViewalloc ]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height-49)];
view3.backgroundColor = [UIColorblueColor];
view3.tag =202;
UIView * view4 = [[UIViewalloc ]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height-49)];
view4.backgroundColor = [UIColorgreenColor];
view4.tag =203;
UIView * view5 = [[UIViewalloc ]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height-49)];
view5.backgroundColor = [UIColorgrayColor];
view5.tag =204;
_view0 = [[UIViewalloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height -49)];
[self.viewaddSubview:_view0];
[_view0addSubview:view5];
[_view0addSubview:view3];
[_view0addSubview:view4];
[_view0addSubview:view2];
[_view0addSubview:view1];
}
#pragma mark - UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
NSInteger tag = item.tag;
UIView * view = [self.viewviewWithTag:tag+100];
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:1];
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUpforView:_view0cache:YES];
[_view0bringSubviewToFront:view];
[UIViewcommitAnimations];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)设置UITabBar自己为代理实现页面的动画转场(MS)
- 设置UITabBar自己为代理实现页面的动画转场(MS)
- 为Fragment设置转场动画
- 设置全局的转场动画
- 设置转场动画的方向
- 不同平台(mac、windows—wpf、web、ios、android)下实现页面的转场动画
- Ping转场动画的实现之二:转场动画
- 为自己的应用程序设置切换动画
- 控制器转场动画自定义(1):push/pop的实现
- 控制器转场动画自定义(2):modal/dismiss的实现
- 实现一个复杂动画的界面转场(Swift)
- viewController自定义转场动画的实现
- 如何实现Ping App的转场动画
- 场景转场动画的Canvas实现
- 5.0新特性转场动画的实现
- 实现类似格瓦拉的转场动画
- 实现类似格瓦拉的动画转场效果
- iOS 转场动画UIViewControllerTransitioningDelegate代理
- 为FragmentDialog添加转场动画
- MySQL中使用子查询IN效率较低的问题
- Java复习笔记6【求四位吸血鬼数字】
- UDP socket programming in winsock
- 黑马程序员——C语言——预处理指令
- Linux socket之四:使用POLL机制处理多连接
- 设置UITabBar自己为代理实现页面的动画转场(MS)
- 解决Qt单元测试自定义类型报错的问题
- 第六题
- Android Studio系列教程三--快捷键
- LeetCode | Climbing Stairs
- 如何安全退出已调用多个Activity的Application?
- CodeForces 204A Little Elephant and Interval
- ARC(三):ARC之前世今生
- Leetcode 12 Integer to Roman整数变罗马