看看:
这是我用来制作渐变的代码:
gradView = [[UIView alloc] initWithFrame:CGRectMake(0, 440, self.view.frame.size.width, 80)];
gradView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sepGrad.png"]];
gradView.alpha = 0.2;
[self.view addSubview:gradView];
.png文件:
为什么iOS4无法正常显示透明的.png?
答案 0 :(得分:0)
我认为这是iOS 4.3中的一个错误,请参阅此答案:https://stackoverflow.com/a/8896838/429331
在你的情况下:
gradView = [[UIView alloc] initWithFrame:CGRectMake(0, 440, self.view.frame.size.width, 80)];
gradView.opaque = YES;
gradView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sepGrad.png"]];
gradView.opaque = NO;
gradView.alpha = 0.2;
[self.view addSubview:gradView];
您也可以尝试省略gradView.opaque = YES;
,我不确定是否真的有必要。