透明。png在iOS 4中不透明,在iOS 5中看起来很好

透明。png在iOS 4中不透明,在iOS 5中看起来很好,ios,png,Ios,Png,看一看: 这是我用来制作渐变的代码: 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 addSub

看一看:

这是我用来制作渐变的代码:

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不能正确显示transparent.png?

我认为这是iOS 4.3中的一个错误,请参见以下答案:

就你而言:

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,我不确定这是否真的有必要。

谢谢你提醒我注意这个错误
gradView.不透明=否
为我修复了它。