_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;
