uitableview-cell删除消息\tableViewForHeader自定义

来源:互联网 发布:阿里云服务器建站教程 编辑:程序博客网 时间:2024/05/21 14:58

yourcell.mm中


-(void)willTransitionToState:(UITableViewCellStateMask)state

{
    [super willTransitionToState:state];
    
    if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
    {
       //显示删除btn
    }
    else
    {
      
    }

}



viewheader

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
   
        if (_Array.count == 0)
        {
            return nil;
        }
        else
        {
            UIImageView *image= [[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, width, h)] autorelease];
            image.backgroundColor = [UIColor blackcolor];
            image.alpha = 0.9f;
            
            UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
            headerLabel.backgroundColor = [UIColor clearColor];
            headerLabel.opaque = NO;
            headerLabel.textColor = [UIColor whiteColor];
            headerLabel.font = [UIFont boldSystemFontOfSize:16];
            headerLabel.frame = CGRectMake(10.0, -10.0, 300.0, 45);
            NSString *key = [_Array objectAtIndex:section];
            if ([key isEqualToString:@"*"])
            {
                headerLabel.text = @"常用联系人";
            }
            else
            {
                headerLabel.text = [_Array objectAtIndex:section];
            }
            [image addSubview:headerLabel];
            [headerLabel release];
            return image;  
        }   
   
}



原创粉丝点击