-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ ; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ ) { ; }else{ ; } } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 20.0; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *reuseIdentifier= @"reuseIdentifier"; PersonalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (cell == nil) { cell = [[PersonalTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; } switch (indexPath.section) { :{ ) { cell.leftImg.image = [UIImage imageNamed:@"sjq_home20.png"]; cell.nameLabel.text = @"图文"; }){ cell.leftImg.image = [UIImage imageNamed:@"sjq_readMode2.png"]; cell.nameLabel.text = @"文章"; }){ cell.leftImg.image = [UIImage imageNamed:@"sjq_music2.png"]; cell.nameLabel.text = @"歌单"; }else{ cell.leftImg.image = [UIImage imageNamed:@"sjq_movice2.png"]; cell.nameLabel.text = @"电影"; } } break; :{ ) { cell.leftImg.image = [UIImage imageNamed:@"nightType.png"]; UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero]; [switchview addTarget:self action:@selector(updateSwitchAtIndexPath:) forControlEvents:UIControlEventValueChanged]; cell.accessoryView = switchview; switchview.on = [User moodsession]; //指定开关两种状态下背景颜色和滑动杆颜色 [[UISwitch appearance] setOnTintColor:[UIColor colorWithRed:///]]; cell.nameLabel.text = @"夜间模式"; }){ cell.leftImg.image = [UIImage imageNamed:@"otherShezhi.png"]; cell.nameLabel.text = @"其他设置"; } } break; default: break; } if ([User moodsession]) { cell.backgroundColor = [UIColor colorWithRed:///]; cell.nameLabel.textColor = [UIColor colorWithRed:///]; self.tableview.backgroundColor = [UIColor grayColor]; }else{ cell.backgroundColor = [UIColor whiteColor]; self.tableview.backgroundColor = [UIColor whiteColor]; cell.nameLabel.textColor = [UIColor blackColor]; } cell.textLabel.font = [UIFont systemFontOfSize:]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ switch (indexPath.section) { :{ ) { PersonTuWenViewController *PersonTuWenView = [self.storyboard instantiateViewControllerWithIdentifier:@"PersonTuWenView"]; PersonTuWenView.charidFromTop = self.loginUser.userId; [self.navigationController pushViewController:PersonTuWenView animated:YES]; }){ }){ }){ } } break; :{ ) { }else{ QiTasetViewController *qitaset = [self.storyboard instantiateViewControllerWithIdentifier:@"qitaset"]; [self.navigationController pushViewController:qitaset animated:YES]; } } break; default: break; } }
效果图: