ios – UITableViewCell Z-Order
发布时间:2020-12-14 18:06:41 所属栏目:百科 来源:网络整理
导读:我有一个包含单元格的uitableview.我试图弄清楚如何调整细胞的z顺序.我想这样做: 但是当我加载tableview时,我得到了这个: 我已经尝试过[tableView sendSubViewToBack:cell].此外,当我滚动到底部然后返回到顶部时,结果如图1所示,但当我向下滚动时,结果如图
我有一个包含单元格的uitableview.我试图弄清楚如何调整细胞的z顺序.我想这样做:
但是当我加载tableview时,我得到了这个: 我已经尝试过[tableView sendSubViewToBack:cell].此外,当我滚动到底部然后返回到顶部时,结果如图1所示,但当我向下滚动时,结果如图2所示.我感谢您的帮助. static NSString *CellIdentifier = @"Cell"; NSString *row = [NSString stringWithFormat:@"%li",(long)indexPath.row]; GetMoreTableViewCell *cell = [_chapters dequeueReusableCellWithIdentifier:CellIdentifier]; NSMutableDictionary *deckCategory = [[_data valueForKey:key] valueForKey:row]; if (cell == nil) { cell = [[GetMoreTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } [tableView bringSubviewToFront:cell]; if([[[_data valueForKey:key] valueForKey:[NSString stringWithFormat:@"%i",indexPath.row]] valueForKey:@"isDefault"] == [NSNumber numberWithBool:YES]) { cell.addButton.hidden = YES; } cell.ttitle.text = [[[_data valueForKey:key] valueForKey:row] valueForKey:@"Name"]; cell.backgroundColor = [UIColor clearColor]; cell.selectionStyle = UITableViewCellSelectionStyleNone; CALayer * l = [cell.cellImage layer]; [l setMasksToBounds:YES]; [l setCornerRadius:10.0]; CALayer * b = [cell.cellBackground layer]; [b setMasksToBounds:YES]; [b setCornerRadius:19.0]; cell.cellImage.image = [UIImage imageNamed:[deckCategory valueForKey:@"Image"]]; if(indexPath.row == 0) { cell.cellBackground.image = [UIImage imageNamed:@"card_green.png"]; } else if(indexPath.row == 1) { cell.cellBackground.image = [UIImage imageNamed:@"card_orange.png"]; } else if(indexPath.row == 2) { cell.cellBackground.image = [UIImage imageNamed:@"card_red.png"]; } return cell; 解决方法
我在UITableViewCells上使用阴影时遇到了同样的问题,屏幕下方的单元格(在Y方向上)的阴影与屏幕顶部的较高阴影重叠.
我的解决方案是根据indexPath在UITableViewCell层上设置Z Position. cell.layer.zPosition = CGFloat(indexPath.row) 我的问题只发生在各个部分.如果后续部分中的单元格也遇到此问题,则需要在计算中添加节号. cell.layer.zPosition = CGFloat(indexPath.section) * 1000.0 + CGFloat(indexPath.row) 如果每个部分中有超过1000行,则增加幻数,或者考虑为什么在应用程序中有1000行;-) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c# – 使用与pagemethod和webmethod相同的datatable的区别
- FLEX PROJECT导入到JAVA WEB工程中,如何在发布的web 工程中
- React Native 使用Realm数据库组件
- MVC——应用Ajax获取不到数据问题解答
- Slfj + Logback 时,基本的 logback.xml 配置
- dark寻觅到的一个牛人的分类总结贴--关于swfupload与java整
- C 11中不可变的“功能”数据结构
- ruby-on-rails – Ruby / Rails语法
- 8种Nosql数据库系统对比
- c -cli – 使用Predicate with Array :: FindAll()编译C/C+