_viewTop = [[UIView alloc]init];
//使用这句话会出现图片错位问题
[_viewTop setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"我的考试-标题栏背景"]]];

正确的做法:

 UIImage *image = [UIImage imageNamed:@"我的考试-标题栏背景"];
    _viewTop.layer.contents = (id) image.CGImage;    // 如果需要背景透明加上下面这句
    _viewTop.layer.backgroundColor = [UIColor clearColor].CGColor;

相关文章:

  • 2022-12-23
  • 2021-04-16
  • 2022-12-23
  • 2021-12-31
  • 2021-07-14
  • 2021-10-10
猜你喜欢
  • 2021-04-04
  • 2021-11-13
  • 2021-06-21
  • 2021-09-03
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案