我试图让我的背景图像适合 Parse 的 logInView 中的所有屏幕尺寸。不幸的是,这段代码并没有达到我期望的效果。
[self.logInView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Backgroundwithlogo.png"]]];
我已将
PFLoginViewController
子类化对我刚才所说的LoginViewController
.我已经尝试调整我导入的图像的大小,但它要么调整得太大,要么太小。如果颜色太小,colorWithPatternImage 会将我的图像平铺在 View 中,并且我的背景图像现在似乎被水平拉伸(stretch)。我试过的:
我已经尝试实现:
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Backgroundwithlogo.png"]];
[self.logInView addSubview:imgView];
[self.logInView sendSubviewToBack:imgView];
imgView.contentMode = UIViewContentModeScaleAspectFit;`
无济于事。我已阅读解析指南 Here .但是他们没有通过 UI 中的大小问题来解决这个问题。任何帮助将不胜感激。
最佳答案
UIImageView *imgView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
imgView.image = [UIImage imageNamed:@"Backgroundwithlogo.png"];
[self.logInView addSubview:imgView];
[self.logInView sendSubviewToBack:imgView];
此外,您可能需要特定的 contentMode。
关于ios - 在 loginView 中解析背景图像,不适合所有 iPhone 设备的屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28286787/