UITableView的cell一些设置

//1.cell取消选中效果
cell.selectionStyle = UITableViewCellSelectionStyleNone;

//2.cell取消自带的下滑下效果
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//3.设置系统自带的cell右边的小箭头
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

//4.点击后,过段时间cell自动取消选中
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
     …………
    //消除cell选择痕迹
    [self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
}
- (void)deselect
{
    [self.tableview deselectRowAtIndexPath:[self.tableview indexPathForSelectedRow] animated:YES];
}

//在UITableView里面,选择了某一个cell以后,点击立刻取消该cell的选中状态,可以使用如下方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    //some functions
    ......

    // 取消选中状态
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 
//或者
[tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消选中
}

5.让tableView不能滑动
_tabelView.scrollEnabled = NO;
6.让tableView不现实滑动条
_tabelView.showsVerticalScrollIndicator = NO;
7.拿到某个cell
[tableView cellForRowAtIndexPath:indexPath];
//8设置cell的背景
    UIView *aView = [[UIView alloc] initWithFrame:cell.contentView.frame];
    aView.backgroundColor=[UIColor colorWithHex:@"47a8ef"];
    cell.selectedBackgroundView = aView;
 //9.自定义cell的image大小
 CGSize itemSize;

    if (indexPath.row==0) {
         itemSize=CGSizeMake(25, 25);
    }
    else if (indexPath.row==3)
    {
        itemSize=CGSizeMake(20, 15);
    }
    else
    {
        itemSize=CGSizeMake(20, 20);
    }

    UIImage*ic;

    if (indexPath.row == _selectCellId) {
        ic=[UIImage imageNamed:selectImageArray[indexPath.row]];
    } else {
        ic=[UIImage imageNamed:imageArray[indexPath.row]];
    }

    UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0);
    CGRect imageRect=CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [ic drawInRect:imageRect];
    cell.imageView.image=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值