我有一张高分辨率图像,我想将其用作视图的背景。但是,当我通过 Interface Builder 或以编程方式添加它时,我只看到它的一部分。这无济于事:
UIImage* _backGround = [UIImage imageNamed:@"background-clean@2x.png"];
CGRect _viewFrame = self.view.frame;
[_backGround drawInRect:_viewFrame];
UIImageView* _backGroundView = [[UIImageView alloc] initWithImage:_backGround];
[self.view addSubview:_backGroundView];
[self.view sendSubviewToBack:_backGroundView];
这也是:
_backGroundView.contentMode =UIViewContentModeScaleAspectFit;
那么问题是如何缩放此图像以使其适合全尺寸的视图,而不管其大小如何?PS对不起我的英语不好。