Commit d34fb20f cgx

中间区域页面布局

1 个父辈 68290a71
正在显示 24 个修改的文件 包含 225 行增加38 行删除
......@@ -14,8 +14,9 @@
D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814DB27FFD92200583D4E /* DSDataSource.m */; };
D01814DF27FFDB6A00583D4E /* HomeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814DE27FFDB6A00583D4E /* HomeTableViewCell.m */; };
D01814E227FFDBB800583D4E /* HomeHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E127FFDBB800583D4E /* HomeHeaderView.m */; };
D01814E5280016EA00583D4E /* CarouselModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E4280016EA00583D4E /* CarouselModel.m */; };
D01814E8280020F900583D4E /* CWPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814E6280020F800583D4E /* CWPageControl.m */; };
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814EA28002A8200583D4E /* DsMiddleView.m */; };
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D01814ED28002DC700583D4E /* HeaderDataModel.m */; };
D027EE2627FB3DC0004BBA61 /* NetLoadingStateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */; };
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2827FB51D0004BBA61 /* DSGifHeader.m */; };
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */; };
......@@ -69,10 +70,12 @@
D01814DE27FFDB6A00583D4E /* HomeTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeTableViewCell.m; sourceTree = "<group>"; };
D01814E027FFDBB800583D4E /* HomeHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeHeaderView.h; sourceTree = "<group>"; };
D01814E127FFDBB800583D4E /* HomeHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeHeaderView.m; sourceTree = "<group>"; };
D01814E3280016EA00583D4E /* CarouselModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CarouselModel.h; sourceTree = "<group>"; };
D01814E4280016EA00583D4E /* CarouselModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CarouselModel.m; sourceTree = "<group>"; };
D01814E6280020F800583D4E /* CWPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CWPageControl.m; sourceTree = "<group>"; };
D01814E7280020F900583D4E /* CWPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CWPageControl.h; sourceTree = "<group>"; };
D01814E928002A8200583D4E /* DsMiddleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DsMiddleView.h; sourceTree = "<group>"; };
D01814EA28002A8200583D4E /* DsMiddleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DsMiddleView.m; sourceTree = "<group>"; };
D01814EC28002DC700583D4E /* HeaderDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HeaderDataModel.h; sourceTree = "<group>"; };
D01814ED28002DC700583D4E /* HeaderDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HeaderDataModel.m; sourceTree = "<group>"; };
D027EE2427FB3DC0004BBA61 /* NetLoadingStateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetLoadingStateView.h; sourceTree = "<group>"; };
D027EE2527FB3DC0004BBA61 /* NetLoadingStateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NetLoadingStateView.m; sourceTree = "<group>"; };
D027EE2727FB51D0004BBA61 /* DSGifHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSGifHeader.h; sourceTree = "<group>"; };
......@@ -254,8 +257,10 @@
D04B3DB227F6F6070022F8DF /* Home.storyboard */,
D04B3DC127F6F9390022F8DF /* HomeViewController.h */,
D04B3DC227F6F9390022F8DF /* HomeViewController.m */,
D01814E3280016EA00583D4E /* CarouselModel.h */,
D01814E4280016EA00583D4E /* CarouselModel.m */,
D01814EC28002DC700583D4E /* HeaderDataModel.h */,
D01814ED28002DC700583D4E /* HeaderDataModel.m */,
D01814E928002A8200583D4E /* DsMiddleView.h */,
D01814EA28002A8200583D4E /* DsMiddleView.m */,
D01814E027FFDBB800583D4E /* HomeHeaderView.h */,
D01814E127FFDBB800583D4E /* HomeHeaderView.m */,
D01814D327FFCCFA00583D4E /* HomeTableView.h */,
......@@ -520,7 +525,6 @@
buildActionMask = 2147483647;
files = (
D04B3D9A27F6D4D90022F8DF /* LeadingController.m in Sources */,
D01814E5280016EA00583D4E /* CarouselModel.m in Sources */,
D0B5ECAC27F2D9DE003EDFE3 /* ViewController.m in Sources */,
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */,
D0B5ECA627F2D9DE003EDFE3 /* AppDelegate.m in Sources */,
......@@ -539,8 +543,10 @@
D076C14327F49DC000340B46 /* TmpViewController.m in Sources */,
D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */,
D0C50B4F27FD832300DC68F0 /* LeadView.m in Sources */,
D01814EB28002A8200583D4E /* DsMiddleView.m in Sources */,
D0C50B4227FD39C800DC68F0 /* UIViewController+FullScreenModal.m in Sources */,
D027EE2927FB51D0004BBA61 /* DSGifHeader.m in Sources */,
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */,
D01814DC27FFD92200583D4E /* DSDataSource.m in Sources */,
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */,
D01814E227FFDBB800583D4E /* HomeHeaderView.m in Sources */,
......
//
// DsMiddleView.h
// DreamSleep
//
// Created by peter on 2022/4/8.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 首页Unity、Lottie区域
@interface DsMiddleView : UIView
@end
NS_ASSUME_NONNULL_END
//
// DsMiddleView.m
// DreamSleep
//
// Created by peter on 2022/4/8.
//
#import "DsMiddleView.h"
#import "HeaderDataModel.h"
@interface DsMiddleView ()
@property (nonatomic, strong) UIButton *unityBtn;
@property (nonatomic, strong) UIButton *balanceBtn;
@property (nonatomic, strong) UIButton *comfortableBtn;
@property (nonatomic, strong) NSArray *middleImgs;
@end
@implementation DsMiddleView
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat width = (kScreenWidth - 2*15 - 14)/2;
[self.unityBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self);
make.leftMargin.equalTo(self).offset(15);
make.width.equalTo(@(width));
make.height.equalTo(@(133*width/165.0));
}];
[self.balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.unityBtn);
make.rightMargin.equalTo(self).offset(-15);
make.width.equalTo(self.unityBtn);
make.height.equalTo(@(62*width/166.0));
}];
[self.comfortableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.balanceBtn);
make.height.equalTo(self.balanceBtn);
make.rightMargin.equalTo(self.balanceBtn);
make.bottom.equalTo(self.unityBtn);
}];
self.height = self.unityBtn.height;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.middleImgs = [HeaderDataModel getDsMiddleImages];
for (int i = 0; i < self.middleImgs.count; i++) {
UIButton *btn = [UIButton new];
[btn setImage:[UIImage imageNamed:self.middleImgs[i]] forState:UIControlStateNormal];
btn.imageView.contentMode = UIViewContentModeScaleAspectFit;
btn.tag = i;
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btn];
if (i == 0) {
self.unityBtn = btn;
} else if (i == 1) {
self.balanceBtn = btn;
} else {
self.comfortableBtn = btn;
}
}
}
return self;
}
- (void)btnAction:(UIButton *)sender {
DSLog(@"tag:%ld", sender.tag);
self.height = 3;
}
@end
//
// CarouselModel.h
// HeaderDataModel.h
// DreamSleep
//
// Created by peter on 2022/4/8.
......@@ -9,8 +9,10 @@
NS_ASSUME_NONNULL_BEGIN
@interface CarouselModel : NSObject
/// HomeHeaderView和DsMiddleView数据model
@interface HeaderDataModel : NSObject
+ (NSArray *)getCarouselImages;
+ (NSArray *)getDsMiddleImages;
@end
NS_ASSUME_NONNULL_END
//
// CarouselModel.m
// HeaderDataModel.m
// DreamSleep
//
// Created by peter on 2022/4/8.
//
#import "CarouselModel.h"
#import "HeaderDataModel.h"
@implementation CarouselModel
@implementation HeaderDataModel
+ (NSArray *)getCarouselImages {
return @[@"banner1", @"banner2", @"banner3", @"banner4"];;
}
+ (NSArray *)getDsMiddleImages {
return @[@"btn_home_qpsleep_normal", @"btn_home_jhrelax_normal", @"btn_home_478relax_normal"];;
}
@end
......@@ -9,8 +9,8 @@
NS_ASSUME_NONNULL_BEGIN
/// 自定义首页头部
@interface HomeHeaderView : UIView
@end
NS_ASSUME_NONNULL_END
......@@ -8,34 +8,43 @@
#import "HomeHeaderView.h"
#import "CWCarousel.h"
#import "CWPageControl.h"
#import "CarouselModel.h"
#import "HeaderDataModel.h"
#import "DsMiddleView.h"
@interface HomeHeaderView () <CWCarouselDatasource, CWCarouselDelegate>
// 轮播图
@property (nonatomic, strong) CWCarousel *barnnerView;
@property (nonatomic, strong) NSArray *imgs;
@property (nonatomic, strong) DsMiddleView *dsMiddleView;
@end
@implementation HomeHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.imgs = [CarouselModel getCarouselImages];
self.imgs = [HeaderDataModel getCarouselImages];
[self addSubview:self.barnnerView];
dispatch_after(1, dispatch_get_main_queue(), ^{
[self.barnnerView freshCarousel];
});
[self addSubview:self.dsMiddleView];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
[self.barnnerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(15);
make.width.mas_equalTo(self);
make.height.mas_equalTo(2*(kScreenWidth - 48)/5);
}];
[self.dsMiddleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.topMargin.equalTo(self.barnnerView.mas_bottom).offset(24);
make.width.mas_equalTo(self);
}];
}
- (CWCarousel *)barnnerView {
......@@ -66,6 +75,14 @@
return _barnnerView;
}
- (DsMiddleView *)dsMiddleView {
if (!_dsMiddleView) {
_dsMiddleView = [[DsMiddleView alloc] init];
_dsMiddleView.backgroundColor = self.backgroundColor;
}
return _dsMiddleView;
}
#pragma mark - CWCarouselDatasource
- (NSInteger)numbersForCarousel {
return self.imgs.count;
......@@ -75,7 +92,7 @@
- (UICollectionViewCell *)viewForCarousel:(CWCarousel *)carousel indexPath:(NSIndexPath *)indexPath index:(NSInteger)index{
UICollectionViewCell *cell = [carousel.carouselView dequeueReusableCellWithReuseIdentifier:@"barnnerCellID" forIndexPath:indexPath];
UIImageView *imgView = [cell.contentView viewWithTag:TmpTag];
if(!imgView) {
if (!imgView) {
imgView = [[UIImageView alloc] initWithFrame:cell.contentView.bounds];
imgView.tag = TmpTag;
imgView.contentMode = UIViewContentModeScaleAspectFit;
......@@ -91,6 +108,7 @@
- (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index {
DSLog(@"did selected at index %ld", index);
// 判断是否登录
}
@end
......@@ -9,6 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
/// 自定义首页tableView
@interface HomeTableView : UITableView
- (instancetype)initDemo;
......
......@@ -20,40 +20,41 @@
- (instancetype)initDemo {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.homeDataSource addDataArray:@[]];
self.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
dispatch_after(2.0, dispatch_get_main_queue(), ^{
dispatch_after(5.0, dispatch_get_main_queue(), ^{
[self.mj_header endRefreshing];
});
}];
[self.homeDataSource addDataArray:@[]];
// [self debugViewShowBorder];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
// banner高度
CGFloat bannerH = 2*(kScreenWidth - 48)/5.0;
// 三分钟即刻入睡按钮宽度
CGFloat width = (kScreenWidth - 2*15 - 14)/2;
CGFloat height = 15 + bannerH + 24 + 133*width/165.0;
make.top.equalTo(self);
make.width.mas_equalTo(self);
make.height.mas_equalTo(@300);
make.height.mas_equalTo(height);
}];
}
- (DSDataSource *)homeDataSource {
if (!_homeDataSource) {
CellConfigureBlock cellBlock = ^(id cell, id model, NSIndexPath * indexPath) {
// [cell configureCell:model];
// [cell configureCell:model];
};
NSString * const homeCellIdentifier = @"HomeCellIdentifier";
_homeDataSource = [[DSDataSource alloc] initWithIdentifier:homeCellIdentifier datas:@[] isSection:NO configureBlock:cellBlock];
self.dataSource = _homeDataSource;
[self registerClass:[HomeTableViewCell class] forCellReuseIdentifier:homeCellIdentifier];
self.tableHeaderView = self.headerView;
}
return _homeDataSource;
......@@ -62,6 +63,7 @@
- (HomeHeaderView *)headerView {
if (!_headerView) {
_headerView = [[HomeHeaderView alloc] init];
// [_headerView debugViewShowBorder];
}
return _headerView;
}
......
......@@ -18,7 +18,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.view = self.homeTV;
// 导航栏背景色
......@@ -69,16 +68,6 @@
}
}
//#pragma mark - Table view data source
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// return 1;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeCell" forIndexPath:indexPath];
// return cell;
//}
- (HomeTableView *)homeTV {
if (!_homeTV) {
_homeTV = [[HomeTableView alloc] initDemo];
......
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "btn_home_478relax_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btn_home_478relax_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "btn_home_478relax_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "btn_home_jhrelax_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btn_home_jhrelax_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "btn_home_jhrelax_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "btn_home_qpsleep_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btn_home_qpsleep_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "btn_home_qpsleep_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!