Iphone UITableView淡入背景
我在网上看到很多人都在问这样一个问题:如何使他们的桌面视图在边缘褪色。有些解决方案几乎奏效。例如:Iphone UITableView淡入背景,iphone,ios,uitableview,Iphone,Ios,Uitableview,我在网上看到很多人都在问这样一个问题:如何使他们的桌面视图在边缘褪色。有些解决方案几乎奏效。例如: CAGradientLayer *maskLayer = [CAGradientLayer layer]; CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor; CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
CAGradientLayer *maskLayer = [CAGradientLayer layer];
CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
maskLayer.colors = [NSArray arrayWithObjects:(__bridge id)innerColor, (__bridge id)outerColor, nil];
maskLayer.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1.0], nil];
maskLayer.bounds = CGRectMake(0, 0,
self.historyTable.frame.size.width,
self.historyTable.frame.size.height + self.headerLabel.frame.size.height);
maskLayer.anchorPoint = CGPointZero;
[self.view.layer addSublayer:maskLayer];
此代码运行良好,但存在一个问题,即它只能将其褪色为纯色。我想能够做的是淡出背景图像(它将有模式,可以改变屏幕到屏幕)。有没有办法做到这一点
谢谢。也有同样的问题,假设我们正在讨论,请更换您的最后一行:
[self.view.layer addSublayer:maskLayer];
关于这一点:
self.historyTable.layer.mask = maskLayer;
基本上跳过教程的最后一步,但将遮罩附加到tableView的层
同时检查答案以获得完整的解决方案,包括处理表格顶部和底部。