如何在4英寸屏幕的iOS6上设置viewcontroller背景图像

如何在4英寸屏幕的iOS6上设置viewcontroller背景图像,ios,iphone,objective-c,ios6,ios7,Ios,Iphone,Objective C,Ios6,Ios7,我需要一个澄清我有图像大小640×1136它是设置视图控制器背景全视图这在iOS 7中设置得很好,因为状态栏与视图合并 self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"iOS-7.png"]]; 但在iOS 6中,我无法将大小设置为640×1136。此图像底部大小为隐藏。如何在iOS 6中处理视图控制器背景上的图像 我怎样才能解决这个问题 UIImageView *imag

我需要一个澄清我有图像大小640×1136它是设置视图控制器背景全视图这在iOS 7中设置得很好,因为状态栏与视图合并

 self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"iOS-7.png"]];

但在iOS 6中,我无法将大小设置为640×1136。此图像底部大小为隐藏。如何在iOS 6中处理视图控制器背景上的图像

我怎样才能解决这个问题

   UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.contentMode = UIViewContentModeScaleToFill;
    [imageView setImage:[UIImage imageNamed:@"iOS-7.png"]];
   // self.view.backgroundColor = [UIColor colorWithPatternImage:imageView.image];

    [self.view addSubview:imageView];

如果我使用上面的代码,效果会很好。感谢您的回答@Greg,但我需要知道为什么在设置self.view backgroundColor时会出现屏幕问题。当您在imageView设置缩放模式下设置图像时:

imageView.contentMode = UIViewContentModeScaleAspectFit;
这将缩放图像以适应视图的全尺寸

//延伸

当您使用colorwithpattern时。。。您可以使用视图大小创建UIImageView,并在调用后使用content mode=UIViewContentModeScaleAspectFit向其添加图像

UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[imageView setImage:YOURIMAGE];
`self.view.backgroundColor = [UIColor colorWithPatternImage:imageView.image];`

因此,iOS7默认情况下将状态栏切换为半透明,并允许内容视图显示在状态栏后面。这不是iOS 6的默认设置。因此,您会看到您的正常视图从状态栏的正下方开始,并且由于您(没有)正确缩放视图,视图被剪裁

对于iOS 6及以下版本,您可以获得类似的效果。将状态栏设置为半透明:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
然后,对于您拥有的每个视图控制器,设置:

myViewController.wantsFullScreenLayout = YES;

这将导致您的视图扩展到半透明状态栏下方,与iOS 7的样式类似。

i'm use only self.view.backgroundColor=[uicolorWithPattern://];查看我更新的问题,然后更改为UIViewContentModeScaleToFill