简体   繁体   English

仅在UIImageView中从边缘调整图像大小

[英]Resize image from edges only in UIImageView

I have a UIImageView that will have an image that will need to be resized to fill the length of that view. 我有一个UIImageView,它将具有需要调整大小以填充该视图的长度的图像。 But unlike resizableImageWithCapInsets: ... I need it to extend the edges (like 2 points inside the image) and maintain the center part of the image unmodified ... 但是与resizableImageWithCapInsets不同:...我需要它来扩展边缘(例如图像内的2个点)并保持图像的中心部分不变。

You perhaps need to set the contentMode property of your image view. 您可能需要设置图像视图的contentMode属性。

[[self imageView] setContentMode:(UIViewContentModeCenter | UIViewContentModeScaleAspectFit)];

These two parameters will center the image within the view as well as scaling the image to fit along the largest dimension. 这两个参数将使图像在视图内居中,并缩放图像以适应最大尺寸。

Have a look at the Apple Documentation reference for this and change the UIViewContentMode to suit your needs. 请参阅Apple文档参考 ,并更改UIViewContentMode以适合您的需求。

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

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