1.快捷创建ImageView
UIImageView *<#imageViewName#> = [[UIImageView alloc] initWithFrame:CGRectMake(<#x#>, <#y#>, <#width#>, <#height#>)];
<#imageViewName#>.layer.masksToBounds = YES;
<#imageViewName#>.layer.cornerRadius = <#imageViewName#>.width/2;
<#imageViewName#>.image = [UIImage imageNamed:@"<#imageName#>"];
[self addSubview:<#imageViewName#>];
2.快捷创建Iabel
UILabel *<#labelName#> = [[UILabel alloc] initWithFrame:CGRectMake(<#x#>, <#y#>, <#width#>, <#height#>)];
<#labelName#>.textColor = <#textColor#>;
<#labelName#>.font = [UIFont systemFontOfSize:16];
<#labelName#>.textAlignment = NSTextAlignmentCenter;
<#labelName#>.textColor = <#textColor#>;
<#labelName#>.font = [UIFont systemFontOfSize:16];
<#labelName#>.textAlignment = NSTextAlignmentCenter;
[self
addSubview:<#labelName#>];
3.快捷创建UIButton
UIButton *<#buttonName#> = [[UIButton alloc]initWithFrame:CGRectMake(<#x#>, <#y#>, <#width#>, <#height#>)];
[<#buttonName#> setTitleColor:<#titleColor#> forState:UIControlStateNormal];
[<#buttonName#> setTitle:@"" forState:UIControlStateNormal];
<#buttonName#>.titleLabel.font = [UIFont systemFontOfSize:<#fontSize#>];
[<#buttonName#> addTarget:self action:@selector(startTime:) forControlEvents:UIControlEventTouchUpInside];
<#buttonName#>.layer.cornerRadius = 2;
<#buttonName#>.layer.masksToBounds = YES;
<#buttonName#>.backgroundColor = <#color#>;
[<#buttonName#> setTitleColor:<#titleColor#> forState:UIControlStateNormal];
[<#buttonName#> setTitle:@"" forState:UIControlStateNormal];
<#buttonName#>.titleLabel.font = [UIFont systemFontOfSize:<#fontSize#>];
[<#buttonName#> addTarget:self action:@selector(startTime:) forControlEvents:UIControlEventTouchUpInside];
<#buttonName#>.layer.cornerRadius = 2;
<#buttonName#>.layer.masksToBounds = YES;
<#buttonName#>.backgroundColor = <#color#>;
[self.view addSubview:<#buttonName#>];
4.快捷创建属性
/**
* <#注释#>
*/
* <#注释#>
*/
@property
(nonatomic,strong)
<#class#> *<#name#>;
5.快捷创建table
-(UITableView *)<#tableName#>{
if (!_<#tableName#>) {
_<#tableName#> = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWith, kScreenHeight) style:UITableViewStylePlain];
_<#tableName#>.dataSource = self;
_<#tableName#>.delegate = self;
_<#tableName#>.rowHeight = <#rowHeight#>;
_<#tableName#>.tableHeaderView = <#headView#>;
_<#tableName#>.tableFooterView = [[UIView alloc] init];
}
return _<#tableName#>;
if (!_<#tableName#>) {
_<#tableName#> = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWith, kScreenHeight) style:UITableViewStylePlain];
_<#tableName#>.dataSource = self;
_<#tableName#>.delegate = self;
_<#tableName#>.rowHeight = <#rowHeight#>;
_<#tableName#>.tableHeaderView = <#headView#>;
_<#tableName#>.tableFooterView = [[UIView alloc] init];
}
return _<#tableName#>;
}
6.快捷创建table数据源
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return <#arrayName#>.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
}
cell.model = <#arrayName#>[indexPath.row];
return cell;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return <#arrayName#>.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
}
cell.model = <#arrayName#>[indexPath.row];
return cell;
}
7.快捷创建table代理
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}