iOS精选博文iOS 控件定制iOS开发

多种样式单行cell的布局

2017-05-09  本文已影响284人  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];
上一篇下一篇

猜你喜欢

热点阅读