UIView没有显示完整的图像

时间:2017-06-24 06:17:32

标签: ios

UIView已遍及整个屏幕,但我在其上设置的图像并未完全显示。而是视图需要一些图像并在整个视图中显示。我使用以下语句来设置图像

[self.view setBackgroundColor:
    [UIColor colorWithPatternImage:[UIImage imageNamed:@"Base-Bg-1.png" ]]
];

1 个答案:

答案 0 :(得分:0)

UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"Base-Bg-1.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self.view setBackgroundColor:[UIColor colorWithPatternImage:image]];

在写这个而不是上面发布的语句时,我的问题就解决了。

相关问题