1 、tableView的编辑功能,自定义左滑的编辑菜单
实现几个代理方法即可
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath; { return UITableViewCellEditingStyleDelete; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { } //自定义 - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(8_0); { UITableViewRowAction *deleteAction=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { NSLog(@"delete row"); }]; UITableViewRowAction *addAttentionAction=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"移入\n关注" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { NSLog(@"attention row"); }]; addAttentionAction.backgroundColor=[UIColor grayColor]; return @[deleteAction,addAttentionAction]; }
2 、collectionView的头的设置
这里只是把collection的第一个item往下移动了一下,使得头留出了一块空地,可用于添加其他view当作表头
实现如下代理即可
//collectionviewcell起始的位置 - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section; { UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTHIPHONE, 99)]; headView.backgroundColor = [UIColor redColor]; [collectionView addSubview:headView]; return CGSizeMake(5, 99);// 这的99即是我们设置的高度 }
这样就会看到collection的上面对出一块红色区域