//继承 ILBaseSettingViewController 类
创建三种类型的单元格
一.箭头
ILSettingArrowItem *push = [ILSettingArrowItem itemWithIcon:@"1" title:@"通用"];
//需要写出来子标题的:
push.subtitle=@"nihao";
//需要push到ILPushNoticeViewController控制器中。 需要写出来---》
push.showVCClass = [ILPushNoticeViewController class];
二.开关
ILSettingSwitchItem *LocationServices = [ILSettingSwitchItem itemWithIcon:@"10" title:@"KVO来实现"];
//保留全局变量
_LocationServices = LocationServices;
//开关必有key来持久化数据
_LocationServices.key = ILSettingShakeChoose;
//1.观察LocationServices中的off属性值
[_LocationServices addObserver:self forKeyPath:@"off" options:NSKeyValueObservingOptionNew context:nil];
//2.观察者响应方法
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
if(_LocationServices.off == YES){
NSLog(@"上面关");
}else{
NSLog(@"上面开");
}
if (_SystemServices.off == YES) {
NSLog(@"下面关");
}else
{
NSLog(@"下面开");
}
}
//3.移除观察者
-(void)dealloc
{
[_LocationServices removeObserver:self forKeyPath:@"off"];
[_SystemServices removeObserver:self forKeyPath:@"off"];
}
三.左字右字的
创建三种类型的单元格
一.箭头
ILSettingArrowItem *push = [ILSettingArrowItem itemWithIcon:@"1" title:@"通用"];
//需要写出来子标题的:
push.subtitle=@"nihao";
//需要push到ILPushNoticeViewController控制器中。 需要写出来---》
push.showVCClass = [ILPushNoticeViewController class];
二.开关
ILSettingSwitchItem *LocationServices = [ILSettingSwitchItem itemWithIcon:@"10" title:@"KVO来实现"];
//保留全局变量
_LocationServices = LocationServices;
//开关必有key来持久化数据
_LocationServices.key = ILSettingShakeChoose;
//1.观察LocationServices中的off属性值
[_LocationServices addObserver:self forKeyPath:@"off" options:NSKeyValueObservingOptionNew context:nil];
//2.观察者响应方法
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
if(_LocationServices.off == YES){
NSLog(@"上面关");
}else{
NSLog(@"上面开");
}
if (_SystemServices.off == YES) {
NSLog(@"下面关");
}else
{
NSLog(@"下面开");
}
}
//3.移除观察者
-(void)dealloc
{
[_LocationServices removeObserver:self forKeyPath:@"off"];
[_SystemServices removeObserver:self forKeyPath:@"off"];
}
三.左字右字的
ILSettingLabelItem *endTime = [ILSettingLabelItem itemWithTitle:@"结束时间"];
// endTime.text = @"23:59";
endTime.key = ILSettingScoreShowEndTime;
if (endTime.text.length == 0) {
endTime.text = @"23:59";
}
ILSettingGroup *endTimeGroup = [[ILSettingGroup alloc] init];
endTimeGroup .items = @[endTime];
[_allGroups addObject:endTimeGroup];