SingleLineLayoutCell
工欲善其事茁帽,必先利其器。面對各種各樣的單行cell因惭,雖然代碼寫起來不難岳锁,但是還是比較繁瑣的,浪費時間筛欢。怎么樣用一種cell直接搞定這些亂七八糟的樣式浸锨,實現(xiàn)快速高效的實現(xiàn)。詳情請看demo源碼版姑,以下是效果圖以及使用方法柱搜。歡迎各位提出建議,指導(dǎo)剥险,star聪蘸。
github源碼地址:https://github.com/HelloYeah/SingleLineLayoutCell
效果圖
示例用法
//彈窗,標題,子標題健爬,圖標控乾,右側(cè)箭頭
{
SingleLineLayoutItem *item0 = [SingleLineLayoutItem itemWithTitle:@"彈窗" subtitle:@"subtitle" icon:@"3" rightType:SingleLineItemRightTypeArrow];
item0.iconWidth = 30;
item0.operation = ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"It is so cool" message:@"Hello World !!! " delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
[alertView show];
};
}
//push,標題娜遵,右側(cè)箭頭
{
SingleLineLayoutItem *item1 = [SingleLineLayoutItem itemWithTitle:@"push到下一控制器" rightType:SingleLineItemRightTypeArrow];
__weak typeof(self) weakSelf = self;
item1.operation = ^{
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor cyanColor];
[weakSelf.navigationController pushViewController:vc animated:YES];
};
}
//標題蜕衡,子標題,圖標设拟,右側(cè)自定義視圖為UIImageView
{
SingleLineLayoutItem *item2 = [SingleLineLayoutItem itemWithTitle:@"標題2" subtitle:@"the subtitle length is so long . oh my god" icon:@"4" rightType:SingleLineItemRightTypeCustomView];
item2.iconWidth = 30;
UIImageView *icon = [[UIImageView alloc] init];
icon.image = [UIImage imageNamed:@"4"];
icon.size = CGSizeMake(30, 30);
item2.rightView = icon;
[_dataArray addObject:item2];
}
//標題慨仿,右側(cè)TypeCheck
{
SingleLineLayoutItem *item3 = [SingleLineLayoutItem itemWithTitle:@"這個標題有點長。真的有點長" rightType:SingleLineItemRightTypeCheck];
[_dataArray addObject:item3];
}
//標題纳胧,子標題镰吆,圖標,右側(cè)箭頭跑慕,右側(cè)自定義視圖為UILabel
{
SingleLineLayoutItem *item4 = [SingleLineLayoutItem itemWithTitle:@"我的收藏(99)" subtitle:@"詳細信息" icon:@"" rightType:SingleLineItemRightTypeArrowAndCustomView];
UILabel *rightLabel = [[UILabel alloc] init];
rightLabel.font = [UIFont systemFontOfSize:13];
rightLabel.text = @"右側(cè)自定義的視圖";
rightLabel.textColor = [UIColor orangeColor];
[rightLabel sizeToFit];
item4.rightView = rightLabel;
}
//帶富文本的標題万皿,子標題,右側(cè)自定義視圖為UISwitch
{
SingleLineLayoutItem *item5 = [SingleLineLayoutItem itemWithTitle:@"我的消息(5)" subtitle:@"詳細信息" rightType:SingleLineItemRightTypeCustomView];
item5.titleAttributes = @{NSForegroundColorAttributeName : [UIColor redColor]};
item5.subTitleAttributes = @{NSForegroundColorAttributeName : [UIColor cyanColor]};
item5.rightView = [[UISwitch alloc] init];
}
TextInputCell
示例用法
TextInputItem *receiverItem = [TextInputItem textInputItemWithPlaceholder:@"請輸入收貨人姓名" text:nil];
TextInputItem *phoneItem = [TextInputItem textInputItemWithWithTitle:@"手機號: " Placeholder:@"請輸入11位手機號" text:@"13000000000"];
//設(shè)置彈出鍵盤的樣式
phoneItem.keyboardType = UIKeyboardTypeNumberPad;
TextInputItem *detailAddressItem = [TextInputItem textInputItemWithTitle:@"詳細地址: " Placeholder:@"請輸入詳細地址" textInputType:TextInputTextView];