apple运动

news/2024/11/24 8:47:52/

第一步
首先创建三个文件夹 MVC
Controller 三个小文件夹
Health 创建继承于UIViewController 的类 名为HealthViewController
Sleep 创建继承于 UIViewController 的类 名为SleepViewController
FourBar
创建继承于 UIViewController 的类 名为TodayViewController
创建继承于 UIViewController 的类 名为HealthDataViewController
创建继承于 UIViewController 的类名为HealthSourceViewController
创建继承于 UIViewController 的类名为MedicalTreatmentEmergencyCardViewController
第二步
在HealthViewController里

<UITableViewDelegate , UITableViewDataSource>
@property (nonatomic , strong)UITableView *tbv;

在viewDidLoad里

//睡眠状况self.title = @"睡眠状况";self.navigationController.navigationBar.prefersLargeTitles = YES;[self table];[self.view addSubview:_tbv];
- (void)table{_tbv = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];_tbv.delegate = self;_tbv.dataSource = self;}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 5;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *oj = @"34";UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:oj];if (!cell) {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:oj];}if (indexPath.row == 0) {_tbv.rowHeight = 250;UILabel *la = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 400, 20)];[la setText:@"到点就寝,按时起床.持之以恒."];[cell addSubview:la];UIImageView *im = [[UIImageView alloc]initWithFrame:CGRectMake(5, 35, 410, 210)];im.image =[UIImage imageNamed:@"222"];[cell addSubview:im];}else if (indexPath.row == 1){_tbv.rowHeight = 30;cell.textLabel.text = @"更早";}else if (indexPath.row == 2){_tbv.rowHeight = 80;UILabel *la1 = [[UILabel alloc]initWithFrame:CGRectMake(7,5 , 50, 20)];[la1 setText:@"步数"];[la1 setTextColor:[UIColor whiteColor]];[cell addSubview:la1];cell.backgroundColor = [UIColor orangeColor];UILabel *la2 = [[UILabel alloc]initWithFrame:CGRectMake(270, 10, 105, 55)];[la2 setText:@"5920步"];la2.font = [UIFont systemFontOfSize:30];// la2.backgroundColor = [UIColor redColor];[cell addSubview:la2];}else if (indexPath.row ==3){_tbv.rowHeight = 50;cell.textLabel.text = @"推荐应用";}else{NSArray *arr  = @[@"1",@"1",@"1",@"1",@"1"];_tbv.rowHeight = 90;for (int i= 0; i<arr.count; i++) {UIButton *bu = [[UIButton alloc]initWithFrame:CGRectMake(15 + 80*i, 10, 70, 70)];[bu setBackgroundImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];[cell addSubview:bu];}}return cell;
}

在SleepViewController里

<UITableViewDelegate , UITableViewDataSource>
@property (nonatomic , strong)UITableView *tbv;

在viewDidLoad 里

self.title = @"健身记录";[self table];self.navigationController.navigationBar.prefersLargeTitles = YES;[self.view addSubview:_tbv];

代码

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{\return 1;
}
- (void)table{_tbv = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];_tbv.delegate = self;_tbv.dataSource = self;}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 6;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *oj = @"34";UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:oj];if (!cell) {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:oj];}if (indexPath.row == 0) {_tbv.rowHeight = 250;UILabel *la = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 300, 20)];[la setText:@"少坐多运动,适度锻炼."];[cell addSubview:la];UIImageView *im = [[UIImageView alloc]initWithFrame:CGRectMake(5, 35, 410, 210)];im.image =[UIImage imageNamed:@"111"];[cell addSubview:im];}else if (indexPath.row == 1){_tbv.rowHeight = 30;cell.textLabel.text = @"今天";}else{_tbv.rowHeight = 80;UILabel *la1 = [[UILabel alloc]initWithFrame:CGRectMake(7,5 , 50, 20)];[la1 setText:@"步数"];[la1 setTextColor:[UIColor whiteColor]];[cell addSubview:la1];cell.backgroundColor = [UIColor orangeColor];UILabel *la2 = [[UILabel alloc]initWithFrame:CGRectMake(270, 10, 105, 55)];[la2 setText:@"5920步"];la2.font = [UIFont systemFontOfSize:30];// la2.backgroundColor = [UIColor redColor];[cell addSubview:la2];}return cell;}

在HealthDataViewController里
导入头文件
#import “SleepViewController.h”
#import “HealthViewController.h”
#define ynwidth self.view.frame.size.width
#define ynheight self.view.frame.size.height

<UITableViewDelegate,UITableViewDataSource , UICollectionViewDelegate,UICollectionViewDataSource>
{UITableView *table;
}
@end
static NSString *reuseCell = @"123";

在viewDidLoad里

self.title=@"健康数据";self.navigationController.navigationBar.prefersLargeTitles = YES;self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(rightbtn)];UISearchBar *ser=[[UISearchBar alloc]initWithFrame:CGRectMake(30, 170, 400, 35)];ser.placeholder=@"搜索";table=[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];table.separatorStyle  = UITableViewCellSeparatorStyleNone;table.delegate=self;table.dataSource=self;[self.view addSubview:table];UIView *HeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ynwidth, 50)];UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, ynwidth, 50)];searchBar.barTintColor = [UIColor whiteColor];[searchBar setBackgroundImage:[UIImage new]];UITextField *searchField  = [searchBar valueForKey:@"searchField"];searchField.backgroundColor = [UIColor lightGrayColor];searchBar.placeholder = @"搜索";searchBar.layer.cornerRadius = 1;searchBar.layer.masksToBounds = YES;[HeaderView addSubview:searchBar];table.tableHeaderView = HeaderView;

代码

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 7;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"sssss"];cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"sssss"];if (indexPath.row == 0) {[self wangge];table.rowHeight = ynwidth - 20+15;UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];// 格子的大小layout.itemSize =  CGSizeMake((ynwidth - 20)/2, (ynwidth - 20)/2);// 行间距layout.minimumLineSpacing = 15;// 列间距layout.minimumInteritemSpacing = 15;UICollectionView *clv = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, (ynwidth - 20)+15) collectionViewLayout:layout];clv.backgroundColor = [UIColor whiteColor];// 2.数据源和代理clv.delegate = self;clv.dataSource = self;// 3. 添加到主视图[cell addSubview:clv];[clv registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseCell];}else{table.rowHeight = 50;NSArray *imageArr = @[@"" , @"jiankangjilu" , @"shenticeliang" , @"shengzhijiankang" , @"shujujieguo" , @"xinzang" , @"zhuyaotizheng"];NSArray *titleArr = @[@"" , @"健康记录" , @"身体测量" , @"生殖健康" , @"数据结果" , @"心脏" , @"主要体征"];
//        cell.imageView.image = [UIImage imageNamed:imageArr[indexPath.row]];
//        cell.imageView.image = [UIImage imageNamed:@"jiankangjilu"];
//        cell.detailTextLabel.text = @"saf";UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 40, 40)];imageView.image = [UIImage imageNamed:imageArr[indexPath.row]];[cell addSubview:imageView];UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 5, 200, 40)];titleLabel.text = titleArr[indexPath.row];[cell addSubview:titleLabel];}return cell;
}
- (void)wangge{}
// 每个分区有几个item (小格子的个数)
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{return 4;
}-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCell forIndexPath:indexPath];// cell 添加背景色cell.backgroundColor = [UIColor yellowColor];// 'could not dequeue a view of kind: UICollectionElementKindCell with identifier 123 - must register a nib or a class for the identifier or//     80/100NSArray *arr = @[@"1",@"2",@"3",@"4"];UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(0,0 , (ynwidth - 20)/2, (ynwidth - 20)/2)];imgV.image = [UIImage imageNamed:arr[indexPath.row]];[cell addSubview:imgV];return cell;}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{if (indexPath.row == 3) {HealthViewController *health = [[HealthViewController alloc] init];[self.navigationController pushViewController:health animated:YES];}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{if (indexPath.row == 1) {SleepViewController *sleep = [[SleepViewController alloc] init];[self.navigationController pushViewController:sleep animated:YES];}
}

在MedicalTreatmentEmergencyCardViewController.m里
#define ynwidth self.view.frame.size.width
#define ynheight self.view.frame.size.height

<UICollectionViewDelegate,UICollectionViewDataSource>@end
static NSString *reuseCell = @"123";

viewDidLoad里

self.title = @"124";self.navigationController.navigationBar.prefersLargeTitles = YES;// 创建流水布局UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];// 格子的大小layout.itemSize =  CGSizeMake((ynwidth - 20)/2, (ynwidth - 20)/2);// 行间距layout.minimumLineSpacing = 15;// 列间距layout.minimumInteritemSpacing = 15;// 分区间距//    layout.sectionInset =  UIEdgeInsetsMake(100, 10, 30, 15);//// 网格视图 (表格 - > 需要注册,需要创建布局)// 1.frameUICollectionView *clv = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, (ynwidth - 20)+15) collectionViewLayout:layout];clv.backgroundColor = [UIColor whiteColor];// 2.数据源和代理clv.delegate = self;clv.dataSource = self;// 3. 添加到主视图[self.view addSubview:clv];// 注/Users/pxy/Desktop/UI下/工程/课堂练习 - 网格/课堂练习 - 网格/Base.lproj/Main.storyboard册网格cell[clv registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseCell];

代码

// 每个分区有几个item (小格子的个数)
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{return 4;
}-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCell forIndexPath:indexPath];// cell 添加背景色cell.backgroundColor = [UIColor yellowColor];// 'could not dequeue a view of kind: UICollectionElementKindCell with identifier 123 - must register a nib or a class for the identifier or//     80/100NSArray *arr = @[@"1",@"2",@"3",@"4"];UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(0,0 , (ynwidth - 20)/2, (ynwidth - 20)/2)];imgV.image = [UIImage imageNamed:arr[indexPath.row]];[cell addSubview:imgV];return cell;}

在ViewController里
导入头文件
#import “TodayViewController.h”
#import “HealthDataViewController.h”
#import “HealthSourceViewController.h”
#import “MedicalTreatmentEmergencyCardViewController.h”

UINavigationController *one = [[UINavigationController alloc] initWithRootViewController:[TodayViewController new]];one.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"今天" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];UINavigationController *two = [[UINavigationController alloc] initWithRootViewController:[HealthDataViewController new]];two.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"健康数据" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];UINavigationController *three = [[UINavigationController alloc] initWithRootViewController:[HealthSourceViewController new]];one.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"健康来源" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];UINavigationController *four = [[UINavigationController alloc] initWithRootViewController:[MedicalTreatmentEmergencyCardViewController new]];four.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"医疗急救卡" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];self.viewControllers = @[one,two,three,four];}

http://www.ppmy.cn/news/221569.html

相关文章

苹果手表表盘时钟与js圆周运动

表盘时钟与圆周运动 实现结果 需求分析&#xff1a; 1、时钟时间按照北京时间进行显示; 2、时针、分针、秒针按照时钟运转标准进行运转&#xff1b; 3、小球跟随秒表围绕表盘进行圆周运动。 代码分析 1、html结构&#xff1a;时针、分针、秒针、小球分别用一个div&#xff…

Apple Watch Series 8功能介绍 watch series 8续航

Apple Watch Series 8采用全天候视网膜显示屏&#xff0c;配有41毫米和45毫米两种尺寸表盘&#xff0c;41毫米表盘高度为41毫米、宽度为35毫米、厚度为10.7毫米&#xff0c;45毫米表盘高度为45毫米、宽度为38毫米、厚度为10.7毫米。表壳拥有铝金属和不锈钢两种材质&#xff0c;…

linux安装gitlab

linux安装gitlab 下载gitlab https://packages.gitlab.com/gitlab/gitlab-ce 我下载的是 gitlab-ce-15.4.5-ce.0.el7.x86_64.rpm el/7版本 下载好的文件上传到 /opt文件夹 &#xff08;文件大小1.05G&#xff09; 安装 默认会安装到 /opt文件中 会出现 gitlab文件夹 rpm…

AB PLC协议开发总结

1. AB PLC 协议 AB PLC 协议是指可编程逻辑控制器&#xff08;Programmable Logic Controller&#xff0c;PLC&#xff09;厂商 Rockwell Automation 公司所研发的一系列通信协议。AB 是 Rockwell Automation 公司旗下品牌 Allen-Bradley 的缩写&#xff0c;因此也被称为 Alle…

本文试图教会你使用 枚举 Enmu,进来了解一下?

枚举是 Java 中的一种特殊类型&#xff0c;它用于表示一组固定值。枚举中定义的每个值称为一个枚举常量&#xff0c;它们在声明时都必须赋予一个固定的值&#xff0c;即枚举值。相比于使用常量或者 final 字段来表示一组固定值&#xff0c;枚举更加类型安全、易读、易维护。 J…

PDF Web Viewer

https://mozilla.github.io/pdf.js/web/viewer.html

递增子序列

1题目 给你一个整数数组 nums &#xff0c;找出并返回所有该数组中不同的递增子序列&#xff0c;递增子序列中 至少有两个元素 。你可以按 任意顺序 返回答案。 数组中可能含有重复元素&#xff0c;如出现两个整数相等&#xff0c;也可以视作递增序列的一种特殊情况。 示例 1…

华为手机双卡有android,华为今后再无双卡双通手机 Mate 8成绝唱

华为今后再无双卡双通手机 Mate 8成绝唱 来源&#xff1a;www.18183.com作者&#xff1a;似水流年时间&#xff1a;2016-11-24 不知道到家发现了没有&#xff0c;新款的华为mate9并没有双卡双待的功能了&#xff0c;本文小编为您带来华为今后再无双卡双通手机 Mate 8成绝唱。 不…