This commit is contained in:
2025-11-10 19:22:31 +08:00
parent 8069b08fab
commit 1dc9560a1f
46 changed files with 691 additions and 33 deletions

View File

@@ -8,41 +8,101 @@
#import "MyVC.h"
#import "MySkinVC.h"
#import "KBSkinDetailVC.h"
#import "KBMyHeaderView.h" //
#import "KBMyListCell.h"
@interface MyVC ()
@interface MyVC () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) BaseTableView *tableView; //
@property (nonatomic, strong) KBMyHeaderView *header; //
@property (nonatomic, strong) NSArray<NSArray<NSDictionary *> *> *data; //
@end
@implementation MyVC
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"My";
label.textColor = [UIColor darkTextColor];
label.font = [UIFont systemFontOfSize:20 weight:UIFontWeightSemibold];
[label sizeToFit];
label.center = self.view.center;
label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:label];
self.view.backgroundColor = [UIColor colorWithHex:0xF5F7FB];
// title + SF Symbols +
self.data = @[
@[@{ @"title": @"Notice", @"icon": @"my_notice_icon", @"color": @(0x60A3FF) }],
@[@{ @"title": @"Share App", @"icon": @"my_share_icon", @"color": @(0xF5A623) }],
@[@{ @"title": @"Feedback", @"icon": @"my_feedback_icon", @"color": @(0xB06AFD) },
@{ @"title": @"E-mail", @"icon": @"my_email_icon", @"color": @(0xFF8A65) },
@{ @"title": @"Agreement", @"icon": @"my_agreement_icon", @"color": @(0x4CD964) },
@{ @"title": @"Privacy Policy", @"icon": @"my_privacy_icon", @"color": @(0x5AC8FA) }]
];
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
// tableHeaderView frame
self.header = [[KBMyHeaderView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, 357)];
self.tableView.tableHeaderView = self.header;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
// MySkinVC *vc = [[MySkinVC alloc] init];
KBSkinDetailVC *vc = [[KBSkinDetailVC alloc] init];
// [self.navigationController pushViewController:vc animated:true];
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
/*
#pragma mark - Navigation
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.data.count; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.data[section].count; }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return CGFLOAT_MIN; }
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *v = [UIView new]; v.backgroundColor = [UIColor clearColor]; return v;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 20; }
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *v = [UIView new]; v.backgroundColor = UIColor.clearColor; return v; }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 64; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
KBMyListCell *cell = [tableView dequeueReusableCellWithIdentifier:[KBMyListCell reuseId]];
if (!cell) { cell = [[KBMyListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[KBMyListCell reuseId]]; }
NSDictionary *info = self.data[indexPath.section][indexPath.row];
cell.itemInfoDic = info;
// section 8
NSInteger rows = [tableView numberOfRowsInSection:indexPath.section];
BOOL isFirst = indexPath.row == 0;
BOOL isLast = indexPath.row == rows - 1;
[cell applyCornersWithFirst:isFirst last:isLast];
// 线线
BOOL showLine = (indexPath.section == 0) && !isLast;
[cell setLineHidden:!showLine];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark - Lazy
- (BaseTableView *)tableView {
if (!_tableView) {
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.backgroundColor = [UIColor colorWithHex:0xF5F7FB];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 线
}
return _tableView;
}
@end