添加基本页面
This commit is contained in:
23
keyBoard/Class/Base/V/BaseCell.h
Normal file
23
keyBoard/Class/Base/V/BaseCell.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// BaseCell.h
|
||||
// keyBoard
|
||||
//
|
||||
// Common base cell with default selection style and hook for setup.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface BaseCell : UITableViewCell
|
||||
|
||||
/// Convenience reuse identifier based on class name
|
||||
+ (NSString *)reuseId;
|
||||
|
||||
/// Override point to add subviews and constraints
|
||||
- (void)setupUI;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
32
keyBoard/Class/Base/V/BaseCell.m
Normal file
32
keyBoard/Class/Base/V/BaseCell.m
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// BaseCell.m
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import "BaseCell.h"
|
||||
|
||||
@implementation BaseCell
|
||||
|
||||
+ (NSString *)reuseId {
|
||||
return NSStringFromClass(self);
|
||||
}
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self setupUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareForReuse {
|
||||
[super prepareForReuse];
|
||||
// Reset state if needed by subclasses
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
// Subclasses override to build UI
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
17
keyBoard/Class/Base/V/BaseTableView.h
Normal file
17
keyBoard/Class/Base/V/BaseTableView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// BaseTableView.h
|
||||
// keyBoard
|
||||
//
|
||||
// A lightweight UITableView subclass for common defaults.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface BaseTableView : UITableView
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
30
keyBoard/Class/Base/V/BaseTableView.m
Normal file
30
keyBoard/Class/Base/V/BaseTableView.m
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// BaseTableView.m
|
||||
// keyBoard
|
||||
//
|
||||
|
||||
#import "BaseTableView.h"
|
||||
|
||||
@implementation BaseTableView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
|
||||
if (self = [super initWithFrame:frame style:style]) {
|
||||
[self commonInit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)commonInit {
|
||||
self.sectionHeaderTopPadding = 0;
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
|
||||
// Disable estimates to avoid jumpy updates for simple lists; tweak per-screen if needed
|
||||
self.estimatedRowHeight = 0;
|
||||
self.estimatedSectionHeaderHeight = 0;
|
||||
self.estimatedSectionFooterHeight = 0;
|
||||
self.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -15,7 +15,16 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
// Simple demo content so the tab is distinguishable
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
label.text = @"Home";
|
||||
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];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#import "BaseTabBarController.h"
|
||||
#import "HomeVC.h"
|
||||
#import "MyVC.h"
|
||||
#import "BaseNavigationController.h"
|
||||
|
||||
@interface BaseTabBarController ()
|
||||
|
||||
@@ -17,7 +18,18 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Setup two tabs: Home & My, each embedded in BaseNavigationController
|
||||
HomeVC *home = [[HomeVC alloc] init];
|
||||
home.title = @"首页";
|
||||
BaseNavigationController *navHome = [[BaseNavigationController alloc] initWithRootViewController:home];
|
||||
navHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:nil selectedImage:nil];
|
||||
|
||||
MyVC *my = [[MyVC alloc] init];
|
||||
my.title = @"我的";
|
||||
BaseNavigationController *navMy = [[BaseNavigationController alloc] initWithRootViewController:my];
|
||||
navMy.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:nil selectedImage:nil];
|
||||
|
||||
self.viewControllers = @[navHome, navMy];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,15 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
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];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user