cell 的 @interface
@interface <#object#>()
@end
cell创建frame
- (instancetype)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
[self setSubView];
}
return self;
}
- (void)setSubView{
}
UILabel
self.label = [[UILabel alloc]initWithFrame:CGRectMake(<#object#>, <#object#>, <#object#>, <#object#>)];
self.label.textAlignment = NSTextAlignmentCenter;
self.label.font = [UIFont systemFontOfSize:<#object#>];
self.label.textColor = [UIColor whiteColor];
self.label.layer.masksToBounds = YES;
self.label.layer.cornerRadius = <#object#>;
self.label.backgroundColor = [UIColor redColor];
[self addSubview:self.label];
UIButton
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(<#object#>,<#object#>,<#object#>,<#object#>);
[button setTitle:<#object#> forState:UIControlStateNormal];
[button setTitleColor:<#object#> forState:UIControlStateNormal];
[button setTitleColor:<#object#> forState:UIControlStateSelected];
button.titleLabel.font = [UIFont systemFontOfSize:<#object#>];
[button addTarget:self action:@selector(buttonActionWithSender:) forControlEvents:UIControlEventTouchUpInside];
button.tag = <#object#>;
[self addSubview:button];
strong
@property (nonatomic,strong) <#Class#> *<#object#>;
整体的页面布局
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = RandomColor;
self.dataSource = [NSMutableArray array];
[self crateTableView];
}
#pragma mark - NetWorking
- (void)getDataFormNetWorking{
WeakSelf(weakSelf);
NSDictionary * params = @{
};
NSString *url = [NSString stringWithFormat:@"%@",@""];
}
#pragma mark - createTableView
- (void)crateTableView{
self.tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
self.tableView.backgroundColor = [UIColor whiteColor];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.tableHeaderView = [self drawTableViewHeaderView];
[self.view addSubview:self.tableView];
// [self.tableView mas_makeConstraints:^(MASConstraintMaker *make)
// {
// make.left.equalTo(self.view.mas_left);
// make.right.equalTo(self.view.mas_right);
// make.top.equalTo(self.view.mas_top);
// make.bottom.equalTo(self.view.mas_bottom);
// }];
if (@available(iOS 11.0, *))
{
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
//默认【下拉刷新】
// self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getDataFormNetWorking)];
}
- (UIView *)drawTableViewHeaderView
{
return [UIView new];
}
#pragma mark - tableViewDataSource Delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.dataSource.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return <#object#>;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;
}
#pragma mark - navigation
- (void)createNavigationBarItem{
UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(<#object#>, <#object#>, <#object#>, <#object#> )];
[rightButton setTitle:<#object#> forState:UIControlStateNormal];
[rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
rightButton.titleLabel.font = [UIFont systemFontOfSize:<#object#>];
[rightButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightBarButtonItem;
}
#pragma mark - buttonClick
- (void)buttonAction:(UIButton *)sender{
}