我与透明度准备的图像,像这样:如何使用colorWithPatternImage时保留图像的透明度:
有两个UIviews,我设置背景色为这样:
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
self.dashedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"red_square.png"]];
我希望重复在与透明度的UIView保留了红色正方形,但它已经通过了坚实的颜色像这样充满:
我不明白为什么。有没有简单的方法来绘制透明平铺图像?或者我需要看看图形核心图形模式?
完美,谢谢。我以前通过Interface Builder尝试过这种方式,但似乎并不奏效。但是,以编程方式设置它。 – msmithstubbs 2010-11-17 21:40:04
这些选项通过IB有一些问题,我已经遇到过很多次。我认为它有潜在的初始化顺序问题。 – 2010-11-17 21:41:18
对于后人,我发现有必要将图层设置为非不透明,例如:[self.dashedView.layer setOpaque:NO]。请参阅:http://stackoverflow.com/questions/4059487/iphone-uiviews-backgroundcolor-using-a-png-with-transparency – tba 2011-05-19 21:25:20