UIview设置背景图片
self.view.backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageNamed:@"title.png"]];set uitableviewcell image background:
UIImageView *bgView = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"title_dept_date.png"]];
bgView.alpha = 0.6;
cell.backgroundView = bgView;UIview在使用PNG 透明图片时遇到,背景为黑色的问题解决:
1. 透明模式,设置backgroundColor属性之后,你需要设置opaque属性为NO在两个视图及其层。下面是一个示例:
UIView* paperView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,700)];
paperView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"paper.png"]];
[paperView.layer setOpaque:NO];
paperView.opaque = NO;2. 我还没有真正做到了这一点,但这里是我想尝试。 设置UIView的
.backgroundColor至[UIColor
clearColor]。然后把包含你的PNG一个UIImageView的“最低”项目的子视图的UIView的堆栈。确保的UIImageView的背景颜色也很清楚。
3. 使用此:myView.backgroundColor=[的UIColor
clearColor]; 这将其设置为透明背景。
本文介绍了如何在iOS应用中使用不同方法为UIview设置背景图片,包括直接设置背景图片、解决透明PNG图片显示黑色背景的问题等。提供了具体的代码示例。
1929

被折叠的 条评论
为什么被折叠?



