透明UITableViewCellanimation时闪烁背景
我有一个自定义背景颜色的UIViewController
。 在它上面有一个UITableView
与UITableViewCells
是半透明的(不透明度为0.5的白色)。
我正在指责的问题和我的头撞墙的问题是在iOS 7中,当你有一个半透明背景的UITableViewCell
,并尝试删除/插入/移动行(所以依靠animation效果)整个UITableView
的单元格闪烁只有0.1秒,并将单元格背景设置为更透明的单元格。 这非常烦人。
我唯一要做的就是设置self.view
的背景颜色:
self.view.backgroundColor = [UIColor colorWithRed:0.4 green:0.5 blue:0.7 alpha:1];
并设置单元格的背景颜色:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5]; }
这里是一个GIF向你展示的问题:
这里是超级简单的项目: https : //github.com/socksz/TransparentCellFlashing
请帮我解决这个荒谬的问题! :P
-
创buildUITableViewCell的子类(如名为:CustomCell),并覆盖CustomCell.m中的方法:
- (id)initWithCoder:(NSCoder *)aDecoder{ self = [super initWithCoder:aDecoder]; if(self){ // Initialization code [self setBackgroundColor:[UIColor clearColor]]; UIView * bgView = [[UIView alloc] initWithFrame:self.frame]; [bgView setBackgroundColor:[UIColor colorWithWhite:1 alpha:0.5]]; [self addSubview:bgView]; } return self; }
-
删除MasterViewController.m中的willDisplayCell方法
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5]; }
-
更改MasterViewController.m中的
cellForRowAtIndexPath
方法- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; [self configureCell:cell atIndexPath:indexPath]; return cell; }
-
更改故事板中单元格的类types
只是有一个尝试:D