美文网首页
2018-01-11 代码块

2018-01-11 代码块

作者: 破夕_____________ | 来源:发表于2018-01-11 11:48 被阅读3次

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{
    
}

相关文章

网友评论

      本文标题:2018-01-11 代码块

      本文链接:https://www.haomeiwen.com/subject/cnuznxtx.html