简体   繁体   English

缩放以适合剪切图像

[英]Scale to fit cuts image

I have an UIImageView with the image of a gradient with a thin line at the bottom. 我有一个UIImageView,底部有一条细线的渐变图像。 As the image isn't the same size as the imageview I want to scale it in some way. 由于图像的大小与imageview的大小不同,因此我想以某种方式缩放它。 I don't care if I stretch the image but I would like the line at the bottom to be visible. 我不在乎是否拉伸图像,但我希望底部的线可见。 Therefore I chose "Scale To Fill". 因此,我选择了“按比例缩放以填充”。 But as you can see on the second screenshot the bottom line is not showing up in the simulator. 但是,如您在第二张屏幕截图中所看到的,模拟器中没有显示底线。

I thought that "Scale to fill" meant that the image got stretched so that all content is visible but that doesn't seem to be the case. 我认为“按比例缩放”意味着图像被拉伸了,以便所有内容都可见,但事实并非如此。

I highly appreciate your answers! 非常感谢您的回答!

在此处输入图片说明

在此处输入图片说明

As the image isn't the same size as the imageview I want to scale it in some way. 由于图像的大小与imageview的大小不同,因此我想以某种方式缩放它。 I don't care if I stretch the image 我不在乎是否拉伸图像

So use a resizable image ( resizableImageWithCapInsets: ). 因此,请使用可调整大小的图像( resizableImageWithCapInsets: This is exactly what it is for. 这正是它的目的。

but I would like the line at the bottom to be visible. 但我希望底部的线可见。

Well, there are some extra complications here, and you are not explaining how you are handling them. 好吧,这里还有一些额外的复杂性,您没有说明如何处理它们。 You have a UIImageView; 您有一个UIImageView; it has a size. 它有一个大小。 Perhaps it is bigger than the view we are seeing in the screen shot. 也许比我们在屏幕快照中看到的视图更大。 Perhaps it is being overlapped by the text view that we see below it. 也许它被我们下面看到的文本视图所覆盖。 In other words, it matters how this image view is being placed in the interface and sized. 换句话说,此图像视图在界面中的放置方式和大小很重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM