背景色(colorWithPatternImage)无法填充iPad的整个视图 [英] Background color (colorWithPatternImage) not filling entire view for iPad

查看:340
本文介绍了背景色(colorWithPatternImage)无法填充iPad的整个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我拥有的方格图像设置背景色.我目前在我的iPhone应用程序中使用此功能,现在正尝试创建通用应用程序.当我使用此功能时:

I am trying to set the background color with a checkered image I have. I am currently using this in my iPhone app and now am trying to create a universal app. When I use this:

 UIImage *bgimg = [UIImage imageNamed:@"square_bg.png"];
 self.view.backgroundColor = [UIColor colorWithPatternImage:bgimg];

它对我的iPhone应用程序正常工作.当它以纵向模式加载到iPad上时,底部大约有20px的空白空间.当它加载到风景中时,就可以了.如果我从纵向旋转到横向,然后再返回,那也很好.

It works fine for my iPhone app. When it loads on the iPad in portrait mode, there is about 20px worth of white space at the bottom. When it loads in landscape, it is fine. If I rotate from portrait to landscape, then back again, it is also fine.

我遗漏了什么,将一直填充到视图的底部?

What am I missing that will fill the pattern all the way to the bottom of my view?

更新

如果我将颜色设置为纯色[UIColor blueColor],则整个屏幕将正确填充.那么,为什么colorWithPatternImage与纯色之间存在差异?

If I set the color to a solid color, [UIColor blueColor], the entire screen fills in correctly. So why the discrepancy from colorWithPatternImage and a solid color?

更新2

我正在使用的文件是尺寸为252x230的PNG文件.我已经使用此图像在该应用程序的iPhone版本中进行了图案制作,没有任何问题.我不确定文件的大小或尺寸是否与此问题有关,但我想我会把它放在那里,以防万一.

The file I am using is a PNG file with dimensions of 252x230. I've used this image to make patterns in the iPhone version of this app with no issues. I'm not sure if the file size or dimensions have any bearing on this issue, but I thought I would put it out there just in case.

推荐答案

20px听起来像状态栏的高度.你能告诉我们镜框吗?

20px sounds like the status bar height. Could you tell us the view frame?

您是否将自动调整大小设置为动态宽度&高度和固定边界?

Is your autoresizing set correctly to dynamic width & height and fixed borders?

这篇关于背景色(colorWithPatternImage)无法填充iPad的整个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆