简体   繁体   English

UITableViewCell渐变层覆盖删除按钮

[英]UITableViewCell Gradient Layer Covering Delete Button

I'm using this answer to create a gradient background for a table view cell 我正在使用此答案为表格视图单元格创建渐变背景

How to make gradient background in UITableViewCell in iOS? 如何在iOS的UITableViewCell中制作渐变背景?

-(void)addGradientBackgroundWithColor:(UIColor *)color {
    if (!self.gradientLayer) {
        self.gradientLayer = [CAGradientLayer layer];
        self.gradientLayer.frame = self.bounds;
        self.gradientLayer.startPoint = CGPointMake(0.0f, 0.5f);
        self.gradientLayer.endPoint = CGPointMake(1.0f, 0.5f);
    }
    self.gradientLayer.colors = @[(id)[[color hmf_makeLightHighlight] CGColor], (id)[[UIColor whiteColor] CGColor]];
    [self.layer insertSublayer:self.gradientLayer atIndex:0];

}

The problem is that when I do a swipe to delete gesture, the gradient layer seems to cover the delete button. 问题是,当我滑动删除手势时,渐变层似乎覆盖了“删除”按钮。

Is there a way to fix this? 有没有办法解决这个问题?

在此处输入图片说明 在此处输入图片说明

Adding this fixed my issue 添加此修复我的问题

- (void)layoutSubviews {
    // resize your layers based on the view's new bounds
    self.gradientLayer.frame = self.bounds;
}

I guess that you insert gradient layer into UITableViewCell. 我猜您将渐变层插入到UITableViewCell中。 I think insert into contentView of UITableViewCell may solve your problem. 我认为插入UITableViewCell的contentView可能会解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM