我正在使用此答案为表格视图单元格创建渐变背景

How to make gradient background in UITableViewCell in iOS?

-(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];

}

问题是,当我滑动删除手势时,渐变层似乎覆盖了删除按钮。

有没有办法来解决这个问题?

ios - UITableViewCell渐变层覆盖删除按钮-LMLPHP ios - UITableViewCell渐变层覆盖删除按钮-LMLPHP

最佳答案

添加此修复我的问题

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

关于ios - UITableViewCell渐变层覆盖删除按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35016342/

10-10 20:50