ios - 在 loginView 中解析背景图像,不适合所有 iPhone 设备的屏幕尺寸

标签 ios objective-c xcode parse-platform

我试图让我的背景图像适合 Parse 的 logInView 中的所有屏幕尺寸。不幸的是,这段代码并没有达到我期望的效果。

[self.logInView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Backgroundwithlogo.png"]]];

我已将 PFLoginViewController 子类化对我刚才所说的LoginViewController .我已经尝试调整我导入的图像的大小,但它要么调整得太大,要么太小。如果颜色太小,colorWithPatternImage 会将我的图像平铺在 View 中,并且我的背景图像现在似乎被水平拉伸(stretch)。

enter image description here

我试过的:

我已经尝试实现:
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/

相关文章:

ios - 失去与 iOS 模拟器的连接

ios - 随机 (lldb) 在 Mac OS X 10.8.4 上的 iOS 模拟器中崩溃

ios - Swift 'fabs' 已弃用 : renamed to 'abs'

objective-c - 如何使用 JSONModel 将 NSArray 序列化为 JSON

objective-c - 如果我在一对多关系中添加相同的 NSManagedObject 几次会发生什么?

ios - 无法将类型 'PFObject' 的值分配给 'PFObject!' 的值,Swift,Xcode

ios - 在 OSX 10.12.1 上构建 'ionic build ios' 失败

ios - 如何解决这个问题 "Ambiguous reference to member ' dataTask(with :completionHandler: )' "

ios - 在 swift 中使用协议(protocol)作为数组类型和函数参数

IOS文字游戏。验证词性能