【问题标题】:Cut out an UIImage to fit inside an UIImageView剪出一个 UIImage 以适应 UIImageView
【发布时间】:2012-03-29 07:07:24
【问题描述】:

我正在开发一个 iOS 4 应用程序。

此问题与UIImageView, setClipsToBounds and how my images are losing their head有关

我有以下问题:

UITableViewCell 上,我有一个UIImageView。此UIImageView 为 77x77 像素,可容纳不同的图片尺寸。

我必须以这种方式处理这些图像:

如果图像是 100x120,我需要从像素 78 到像素 100(宽度)和 78 到 120(高度)。另一种选择是创建另一个删除这些像素。

我该怎么做?

【问题讨论】:

标签: ios cocoa-touch uiimageview uiimage


【解决方案1】:

尝试将图像视图的contentMode设置为UIViewContentModeTopLeft

希望它会有所帮助。

【讨论】:

  • 但是,图像的宽度小于 UIImageView 的宽度(或相同的宽度高度),我该如何缩放图像?谢谢你的回答。
  • 我以为您想剪切(裁剪)图像,而不是调整大小。所以正如@Lukas 指出的那样使用 UIViewContentModeScaleAspectFit
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-08-08
  • 1970-01-01
  • 2012-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-14
相关资源
最近更新 更多