登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

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

[复制链接]
来自: 你们纯洁哥 分类: iOS精品源码 上传时间: 2017-12-23 12:34:18
Tag:

项目介绍:

使用方法很简单,继承我的控制器,然后重写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地址:https://github.com/jolincheng/CZHSettingController

博客地址:http://blog.csdn.net/HurryUpCheng/article/details/78879275

简书地址:https://www.jianshu.com/p/d972b17d0f2c

相关源码推荐:

我来说两句
*滑动验证:
所有评论(5)
逆鳞九霄 2017-12-25 12:07:22
很给力,Code4App有你更精彩!
回复
逆鳞九霄 2017-12-25 12:08:10
楼主用心了,内容非常精彩。
回复
BlueManlove 2017-12-25 12:08:22
膜拜大神~
回复
phoiu 2017-12-25 12:08:56
内容很好,棒棒哒
回复
littleRed 2017-12-25 12:10:22
写的真的很不错
回复
AlonMessi 2017-12-25 12:12:57
code4app确实是个好地方,必须支持~
回复
hellokenken 2017-12-25 12:22:09
不错不错,楼主辛苦了。。。
回复
kengsir 2017-12-25 12:27:08
感谢分享,code4app有你更精彩
回复
code4app热心网友 2017-12-25 15:52:03
很给力,Code4App有你更精彩!
回复
提取码:  下载次数:35 状态:已购或VIP 售价:0(原价:15)金钱 下载权限:初级码农 
762 0 35
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表