调整大小的图像(320x480)不是全屏? iPhone的全屏尺寸是多少?

发布于 2025-01-07 03:29:27 字数 372 浏览 0 评论 0原文

我正在尝试在 iPhone 中将图像大小(来自 URL)调整为全屏。然而,应该是全尺寸的320x480尺寸并不是全屏。

-(IBAction)changeFullSize{
    urlImage.contentMode = UIViewContentModeScaleAspectFit;
    urlImage.frame = CGRectMake(0,0,320,480);
}

我在这里使用 UIButton,因此当用户单击不透明按钮时,它会更改为全尺寸图像。

但是,顶部的选项卡栏和图片开头之间有一个空白区域。

全屏的正确尺寸是多少?有没有办法让它自动调整大小到全屏,而无需我指定宽度和高度?

谢谢。

I'm trying to to resize my image (from URL) to full screen in my iPhone. However, the size 320x480 which is supposed to be full size is not full screen.

-(IBAction)changeFullSize{
    urlImage.contentMode = UIViewContentModeScaleAspectFit;
    urlImage.frame = CGRectMake(0,0,320,480);
}

I'm using a UIButton here, so when the user clicks on the opaque button, it changes to a full sized image.

However, there is an empty space between the tab bar at the top and the start of the picture.

What is the correct size for full screen? Is there a way for it to automatically resize to full screen without me specifying the width and height?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那伤。 2025-01-14 03:29:27

您可以尝试从 self.view.frame.size 获取它,但对于整个屏幕,您可以使用 [[UIScreen mainScreen]bounds] 。希望这有帮助。

You could try and get it from self.view.frame.size but for the entire screen you can use [[UIScreen mainScreen] bounds]. Hope this helps.

‖放下 2025-01-14 03:29:27

您不能仅通过更改其框架来调整图像大小,因为您使用的是宽高比适合,图像将保持其原始宽高比,根据您的需要,

如果缩放填充不能产生您预期的结果, 一个简单的方法是更改​​为 UIViewContentModeScaleToFill,您可能想查看 Trevor 关于 uiimage 类别的博客文章 此处
添加 UIImage 类别后,您可以

[youruiimage resizedImage:CGSizeMake(320, 480) interpolationQuality:kCGInterpolationHigh]

使用它来执行,您可以使用 UIViewContentModeScaleToFill 或 UIViewContentModeScaleAspectFit ,结果应该很好 =)

you cant just resize your image by changing its frame, since you are using aspect fit, the image will keep its original aspect, depending on your needs a simple way would be to change to UIViewContentModeScaleToFill

if scaling to fill does not produce your intended results, you may want to check out trevor's blog post on uiimage categories here
once the UIImage categories are added you can just perform

[youruiimage resizedImage:CGSizeMake(320, 480) interpolationQuality:kCGInterpolationHigh]

using this you can use either UIViewContentModeScaleToFill or UIViewContentModeScaleAspectFit and it should turn out nicely =)

木有鱼丸 2025-01-14 03:29:27

如果您有状态栏,请不要忘记从高度上减小其尺寸。

而且宽高比也会使图像保持正确的比例,然后考虑填充它。

宽高比填充将使图像保持正确的比例+将尝试全屏显示,没有空白空间,可能图像的某些部分不会显示。

缩放至填充将使图像保持全屏,比例并不重要。

If you have status bar then don't forget to reduce its size from the height.

And also aspect-fit would keep the image in its correct ratio, then consider filling it.

Aspect-fill would keep the image in correct ration + will try to make full screen, no void spaces, chances are some part of image wont be shown.

Scale to fill will keep the image full screen, ratio doesn't matter there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文