iOS学习笔记-092.彩票07——竞技场
来源:互联网 发布:剑三丐姐官方捏脸数据 编辑:程序博客网 时间:2024/04/30 06:23
- 彩票07竞技场
- 一图示
- 二界面分析
- 三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];}.....
阅读全文
0 0
- iOS学习笔记-092.彩票07——竞技场
- iOS学习笔记-091.彩票06——我的彩票
- iOS学习笔记-086.彩票01——框架搭建
- iOS学习笔记-087.彩票02——自定义tabBar
- iOS学习笔记-096.彩票11——新特性
- iOS学习笔记-088.彩票03——设置导航条
- iOS学习笔记-093.彩票08——发现和全部采种
- iOS学习笔记-094.彩票09——隐藏底部tabar和统一设置返回按钮
- iOS学习笔记-095.彩票10——滑动移除控制器全屏实现
- iOS学习笔记-097.彩票12——设置1_数据模型创建
- iOS学习笔记-098.彩票13——设置2_UITableViewCell创建
- iOS学习笔记-099.彩票14——设置3_UITableViewController基类提取
- IOS学习之——彩票应用开发
- iOS学习笔记-089.彩票04——购彩大厅1_导航栏左边按钮与修改插件
- iOS学习笔记-090.彩票05——购彩大厅2_自定义蒙版、popMenu、UIView分类抽取
- iOS学习笔记-100.彩票15——设置4_设置和推送提醒控制器创建
- iOS菜鸟成长笔记(2)——网易彩票练习
- Python学习03 — 从11Game 爬取dota竞技场 TOP 100 用户名
- VS2010 解决控制台窗口一闪而过的问题
- 【JavaSE笔记】反射_枚举_JDK新特性
- 【学习笔记】Vue响应式原理
- poj2253—Frogger (并查集最短路)
- Saprk 报错java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
- iOS学习笔记-092.彩票07——竞技场
- bzoj1552robotic sort splay
- Java读取文件内容的几种方式
- 为什么浮点数一定是有误差的
- 书中自有颜如玉,书中不乏漫天坑
- Codeforces AIM Tech Round 4 (Div. 2) 总结
- luogu3847 [TJOI2007]调整队形(dp求变回文的最小操作)
- SSL编程
- javascript数据结构系列(五)-串(2)