ios 快速创建静态动态单元格的设置页面

QQ20171223-122025-HD1.gif

使用方法很简单,继承我的控制器,然后重写czh_setGroup方法,如果满足不了自己的需求,可以自己扩展item然后在frameModel和cell里面书写,如果设置动态在请求完成后在调用czh_setGroup,记得清空数组

- (void)czh_setGroup {
    [super czh_setGroup];

    CZHWeakSelf(self);

    CZHAvatartem *avatartem = [CZHAvatartem itemWithImageName:nil title:@"头像" canClick:YES];
    avatartem.avater = @"http://static.yygo.tv/avatar/185/59e45f2f0d640.png";

    CZHSettingFrameModel *avatarFrameModel = [[CZHSettingFrameModel alloc] init];
    avatarFrameModel.item = avatartem;


    CZHBadgeItem *friendItem = [CZHBadgeItem itemWithImageName:@"mine_friend" title:@"好友" canClick:YES];
    friendItem.badge = @"3";
    friendItem.descVc = [CZHViewController class];

    CZHSettingFrameModel *friendFrameModel = [[CZHSettingFrameModel alloc] init];
    friendFrameModel.item = friendItem;

    CZHFitImageItem *fitItem = [CZHFitImageItem itemWithImageName:@"mine_introduce" title:nil canClick:YES haveLine:YES];
    fitItem.descVc = [CZHViewController class];

    CZHSettingFrameModel *fitFrameModel = [[CZHSettingFrameModel alloc] init];
    fitFrameModel.item = fitItem;



    //昵称
    CZHEditArrowItem *nicknameItem = [CZHEditArrowItem itemWithImageName:nil title:@"昵称" canClick:YES] ;
    nicknameItem.detail = @"hahaha";
    nicknameItem.editCompleteBlock = ^(NSString *inputString) {//编辑完成回调
        CZHStrongSelf(self);

        NSLog(@"---%@", inputString);

    };
    CZHSettingFrameModel *nicknameModel = [[CZHSettingFrameModel alloc] init];
    nicknameModel.item = nicknameItem;


    ///版本号
    CZHBaseSettingItem *versionItem = [CZHBaseSettingItem itemWithImageName:nil title:@"版本号" canClick:NO haveLine:YES];
    versionItem.detail = [NSString stringWithFormat:@"V%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
    CZHSettingFrameModel *versionModel = [[CZHSettingFrameModel alloc] init];
    versionModel.item = versionItem;


    BOOL isOn = YES;
    CZHSwitchItem *soldItem = [CZHSwitchItem itemWithImageName:nil title:@"这是开关标题" canClick:YES haveLine:YES];
    soldItem.isOn = isOn;
    soldItem.detail = isOn ? @"打开" :  @"关闭";

    CZHSettingFrameModel *soldModel = [[CZHSettingFrameModel alloc] init];
    soldModel.item = soldItem;

    soldItem.switchBlock = ^(CZHSwitchItem *item, NSIndexPath *indexPath, BOOL isOn) {
        CZHStrongSelf(self);



        item.isOn = !isOn;
        item.detail = item.isOn ? @"打开" :  @"关闭";

        soldModel.item = item;

        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
    };


    //退出
    CZHExitItem *exitItem = [CZHExitItem itemWithImageName:nil title:@"退出登录" canClick:YES];
    exitItem.operationBlock = ^(CZHBaseSettingItem *item, NSIndexPath *indexPath) {
        NSLog(@"点击退出登录");
    };
    CZHSettingFrameModel *exitModel = [[CZHSettingFrameModel alloc] init];

    exitModel.item = exitItem;


    CZHSectionItem *sectionZero = [[CZHSectionItem alloc] init];
    sectionZero.headHeight = 20;
    sectionZero.items = @[avatarFrameModel];
    [self.sectionGroups addObject:sectionZero];

    CZHSectionItem *sectionOne = [[CZHSectionItem alloc] init];
    sectionOne.headHeight = 20;
    sectionOne.items = @[friendFrameModel, fitFrameModel];
    [self.sectionGroups addObject:sectionOne];

    CZHSectionItem *sectionTwo = [[CZHSectionItem alloc] init];
    sectionTwo.headHeight = 20;
    sectionTwo.items = @[nicknameModel, versionModel, soldModel];
    [self.sectionGroups addObject:sectionTwo];

    CZHSectionItem *sectionThree = [[CZHSectionItem alloc] init];
    sectionThree.headHeight = 50;
    sectionThree.items = @[exitModel];
    [self.sectionGroups addObject:sectionThree];
}

github地址
简书地址

公司的项目.png

公司的项目,求支持,如果发现什么问题,可以留言反应,感激不尽

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值