UIImage *image = [UIImage imageNamed:@"bgimagename"];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 100)];
    //view.backgroundColor = [UIColor colorWithPatternImage:image]; //这种是正常的图片转成背景色
    view.layer.contents = (id)image.CGImage;//这种的比较好,可支持半透明,兼容性又好。
    [self.view addSubview:view];

相关文章:

  • 2021-08-30
  • 2021-10-29
  • 2022-03-08
  • 2021-09-15
  • 2022-12-23
  • 2021-12-18
  • 2021-07-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-08-07
  • 2022-01-16
  • 2021-06-25
相关资源
相似解决方案