
我正在责备的问题和我撞到墙上的问题是在iOS 7中,当你有一个半透明背景的UItableVIEwCell并且你试图删除/插入/移动行时(依赖于动画)效果)整个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
解决方法 >创建UItableVIEwCell的子类(如named: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;} >在故事板中更改单元格的类类型
试一试:D
总结以上是内存溢出为你收集整理的ios – 动画时透明的UITableViewCell闪烁背景全部内容,希望文章能够帮你解决ios – 动画时透明的UITableViewCell闪烁背景所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)