Latest 0.0.3
Homepage https://github.com/Jackdx/DXSetting
License MIT
Platforms ios 7.0, requires ARC
Authors

Build Status
Cocoapods Compatible
Build Status
Build Status

大部分应用都有设置模块,每次写都差不多,就封装了下,应该可以适配绝大部分的设置界面的需求了。

效果演示:

image

Installation with CocoaPods

    pod 'DXSetting'

How To Use

直接继承DXBaseSettingViewController,实现以下方法就可以实现设置页面的显示。

简单的cell

__weak typeof(self) weakSelf = self;
// 1.1.新消息通知
DXSettingItem *push = [DXSettingItem itemWithIcon:@"MorePush" title:@"新消息通知" type:DXSystemSettingItemTypeArrow];
//cell点击事件
push.operation = ^{
DXPushNoticeViewController *notice = [[DXPushNoticeViewController alloc] init];
[weakSelf.navigationController pushViewController:notice animated:YES];
};

// 1.2.声音提示
DXSettingItem *shake = [DXSettingItem itemWithIcon:@"sound_Effect" title:@"声音提示" type:DXSystemSettingItemTypeSwitch];
//开关事件
shake.switchBlock = ^(BOOL on) {
NSLog(@"声音提示%zd",on);
};

DXSettingGroup *group = [[DXSettingGroup alloc] init];
group.sectionHeaderTitle = @"简单设置";
group.items = @[push, shake];
[self.allGroups addObject:group];

复杂的cell

__weak typeof(self) weakSelf = self;
// 1.1.手机号
DXSettingItem *phone = [DXSettingItem itemWithIcon:@"MorePush" title:@"手机号" detailTitle:@"18671717171" type:DXSystemSettingItemTypeArrow];
//cell点击事件
phone.operation = ^{
UIViewController *phoneVC = [[UIViewController alloc] init];
phoneVC.view.backgroundColor = [UIColor brownColor];
phoneVC.title = @"手机号";
[weakSelf.navigationController pushViewController:phoneVC animated:YES];
};

// 1.2.复杂cell
DXSettingItem *shake = [DXSettingItem itemWithIcon:@"sound_Effect" title:@"特别" detailTitle:@"我是描述文字" type:DXSystemSettingItemTypeSwitch style:UITableViewCellStyleSubtitle];
//开关事件
shake.switchBlock = ^(BOOL on) {
NSLog(@"声音提示%zd",on);
};

DXSettingGroup *group = [[DXSettingGroup alloc] init];
group.sectionHeaderTitle = @"复杂设置";
group.items = @[phone, shake];
[self.allGroups addObject:group];

Latest podspec

{
    "name": "DXSetting",
    "version": "0.0.3",
    "summary": "An easy setting",
    "homepage": "https://github.com/Jackdx/DXSetting",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jackdx": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Jackdx/DXSetting.git",
        "tag": "0.0.3"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "DXSetting/**/*.{h,m}"
}

Pin It on Pinterest

Share This