多种样式单行cell的布局

SingleLineLayoutCell

  • 工欲善其事,必先利其器。面对各种各样的单行cell,虽然代码写起来不难,但是还是比较繁琐的,浪费时间。怎么样用一种cell直接搞定这些乱七八糟的样式,实现快速高效的实现。详情请看demo源码,以下是效果图以及使用方法。欢迎各位提出建议,指导,star。

  • github源码地址:https://github.com/HelloYeah/SingleLineLayoutCell

效果图

1.gif

示例用法

   //弹窗,标题,子标题,图标,右侧箭头
   {
        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,标题,右侧箭头
    {
        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];
        };
    }
    
    //标题,子标题,图标,右侧自定义视图为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];
    }
    
    //标题,右侧TypeCheck
    {
        SingleLineLayoutItem *item3 = [SingleLineLayoutItem itemWithTitle:@"这个标题有点长。真的有点长"  rightType:SingleLineItemRightTypeCheck];
        [_dataArray addObject:item3];
    }
    
    //标题,子标题,图标,右侧箭头,右侧自定义视图为UILabel
    {
        SingleLineLayoutItem *item4 = [SingleLineLayoutItem itemWithTitle:@"我的收藏(99)" subtitle:@"详细信息" icon:@"" rightType:SingleLineItemRightTypeArrowAndCustomView];
        UILabel *rightLabel = [[UILabel alloc] init];
        rightLabel.font = [UIFont systemFontOfSize:13];
        rightLabel.text = @"右侧自定义的视图";
        rightLabel.textColor = [UIColor orangeColor];
        [rightLabel sizeToFit];
        item4.rightView = rightLabel;
    }
    
     //带富文本的标题,子标题,右侧自定义视图为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

2.gif

示例用法

    TextInputItem *receiverItem = [TextInputItem textInputItemWithPlaceholder:@"请输入收货人姓名" text:nil];
    
    TextInputItem *phoneItem = [TextInputItem textInputItemWithWithTitle:@"手机号: " Placeholder:@"请输入11位手机号" text:@"13000000000"];
    //设置弹出键盘的样式
    phoneItem.keyboardType = UIKeyboardTypeNumberPad;
    
    TextInputItem *detailAddressItem = [TextInputItem textInputItemWithTitle:@"详细地址: " Placeholder:@"请输入详细地址" textInputType:TextInputTextView];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,090评论 25 708
  • 刚刚看了黄磊先生的《深夜食堂》。五分钟。我终于明白为什么网上这么多人骂他了。 也许黄磊先生以为我们中...
    一叶茶阅读 487评论 0 0
  • 天南有鸟,其名为离,一生一侣,失则往殉。大哉天帝,不忍其态,复造神鸟,娇覆八荒,离不斜视,转触天柱,三触乃死
    飖颺阅读 179评论 0 0
  • 7.14 子在齐闻《韶》,三月不知肉味,曰:“不图为乐之至于斯也。”——孔子在齐国听到了《韶》乐,有很长时间尝不出...
    共剪西窗烛阅读 367评论 0 0
  • 今天一大早就去看电影《战狼2》了,虽然有遗憾,但很快就被电影情节冲淡。在看这部电影的时候,突然蹦出这些问题,当时没...
    济夏阅读 671评论 0 51