iOS学习笔记-092.彩票07——竞技场
2017-08-25 22:40
330 查看
彩票07竞技场
一图示
二界面分析
三QWMArenaViewControllerm
四QWMArenaNavigationControllerm
五QWMTabBarViewControllerm 修改
第二、我们发现我们的 导航条 和其他是不一样的,那么我们可以定制一下我们的 导航控制器(QWMArenaNavigationController)。修改我们的导航条的背景。
第三、选项卡的问题,上面的选项卡我们可以在控制器中创建 UISegmentedControl,然后添加到导航条中。
第四、在 QWMTabBarViewController 创建导航控制器的时候,竞技场 使用我们的 导航控制器。
如下面
一图示
二界面分析
三QWMArenaViewControllerm
四QWMArenaNavigationControllerm
五QWMTabBarViewControllerm 修改
彩票07——竞技场
一、图示
二、界面分析
首先来看背景,背景是一张图片,我们可以创建一个 ImageView 来设置背景,让它能够交互第二、我们发现我们的 导航条 和其他是不一样的,那么我们可以定制一下我们的 导航控制器(QWMArenaNavigationController)。修改我们的导航条的背景。
第三、选项卡的问题,上面的选项卡我们可以在控制器中创建 UISegmentedControl,然后添加到导航条中。
第四、在 QWMTabBarViewController 创建导航控制器的时候,竞技场 使用我们的 导航控制器。
三、QWMArenaViewController.m
这个类是竞技场的控制器,这个控制器里面我们主要 创建背景和设置我们的选项卡。// // QWMArenaViewController.m // 03_UIView79_彩票 // // Created by 杞文明 on 17/7/24. // Copyright © 2017年 杞文明. All rights reserved. // #import "QWMArenaViewController.h" @interface QWMArenaViewController () @end @implementation QWMArenaViewController // 当第一次加载view的时候调用 // 如果自定义view,重写这个方法 -(void)loadView{ // 在这个方法里面不能调用self.view.bounds,如果调用会造成死循环 //创建UIImageView UIImageView *imageView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; self.view = imageView; //设置背景图片 imageView.image = [UIImage imageNamed:@"NLArenaBackground"]; //设置允许与用户交互 imageView.userInteractionEnabled = YES; } - (void)viewDidLoad { [super viewDidLoad]; //1.设置titleView UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:@[@"足球",@"篮球"]]; //2.设置背景图片 //普通状态 [segmentedControl setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentBG"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; //选中状态 [segmentedControl setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentSelectedBG"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault]; //3.设置字体颜色 [segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal]; //4/设置选中的索引 segmentedControl.selectedSegmentIndex = 0; //5.设置前景色 segmentedControl.tintColor = [UIColor colorWithRed:0 green:142/255.0 blue:143/255.0 alpha:1]; self.navigationItem.titleView = segmentedControl; } @end
四、QWMArenaNavigationController.m
这个是竞技场的导航控制器,修改导航条的背景。// // QWMArenaNavigationController.m // 03_UIView79_彩票 // // Created by 杞文明 on 17/8/24. // Copyright © 2017年 杞文明. All rights reserved. // #import "QWMArenaNavigationController.h" @interface QWMArenaNavigationController () @end @implementation QWMArenaNavigationController +(void)initialize{ //1.获取导航条标识 UINavigationBar *bar = [UINavigationBar appearanceWhenContainedIn:self, nil]; //2.设置导航条背景色 UIImage *image = [UIImage imageNamed:@"NLArenaNavBar64"]; image = [image stretchableImageWithLeftCapWidth:image.size.width/2 topCapHeight:image.size.height/2]; [bar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; } @end
五、QWMTabBarViewController.m 修改
在 QWMTabBarViewController 创建导航控制器的时候,竞技场 使用我们的 QWMArenaNavigationController 导航控制器如下面
// // QWMTabBarViewController.m // 03_UIView79_彩票 // // Created by 杞文明 on 17/7/24. // Copyright © 2017年 杞文明. All rights reserved. // #import "QWMTabBarViewController.h" #import "QWMHallTableViewController.h" #import "QWMArenaViewController.h" #import "QWMDiscoverTableViewController.h" #import "QWMHistoryTableViewController.h" #import "QWMMyLotteryViewController.h" #import "QWMTabBar.h" #import "QWMNavigationController.h" #import "QWMArenaNavigationController.h" @interface QWMTabBarViewController ()<QWMTabBarDelegate> /** taBBar item 模型数组 */ @property (nonatomic, strong) NSMutableArray *items; @end @implementation QWMTabBarViewController ...... //添加一个子控制器 -(void)setupOneChildViewController:(UIViewController *)vc image:(UIImage *)image selImage:(UIImage *)selImage title:(NSString *)title{ // [self addChildViewController:vc]; //设置我们控制器的一些属性 vc.tabBarItem.image = image; vc.tabBarItem.selectedImage = selImage; [self.items addObject:vc.tabBarItem]; //添加标题 vc.navigationItem.title = title; //创建自己的导航条 UINavigationController *nav; if([vc isKindOfClass:[QWMArenaViewController class]]){ //如果是竞技场,我们使用 竞技场导航控制器 nav = [[QWMArenaNavigationController alloc]initWithRootViewController:vc]; }else{ nav = [[QWMNavigationController alloc]initWithRootViewController:vc]; } [self addChildViewController:nav]; } .....
相关文章推荐
- iOS学习笔记-095.彩票10——滑动移除控制器全屏实现
- 黑马程序员——Objective-C程序设计(第4版)学习笔记之07-类——黑马 IOS 技术博客
- iOS学习笔记-097.彩票12——设置1_数据模型创建
- iOS学习笔记-096.彩票11——新特性
- iOS学习笔记-098.彩票13——设置2_UITableViewCell创建
- iOS学习笔记07—Objective-C 委托、非正式协议、正式协议
- IOS学习笔记 ---- 15/09/07
- IOS学习笔记07---C语言函数-printf函数
- iOS学习笔记-099.彩票14——设置3_UITableViewController基类提取
- iOS学习笔记-100.彩票15——设置4_设置和推送提醒控制器创建
- IOS学习笔记07---C语言函数-scanf函数
- iOS学习笔记-087.彩票02——自定义tabBar
- iOS学习笔记07-运动事件和远程控制
- iOS学习笔记07-运动事件和远程控制
- iOS学习笔记-101.彩票16——设置5_开奖推送和比分直播和空白的控制器创建
- iOS学习笔记-093.彩票08——发现和全部采种
- iOS学习笔记07-运动事件和远程控制
- iOS学习笔记-090.彩票05——购彩大厅2_自定义蒙版、popMenu、UIView分类抽取
- iOS学习笔记-147.网络07——NSURLConnection04_简单JSON的解析
- iOS学习笔记-088.彩票03——设置导航条