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]; 这将其设置为透明背景。


Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐