- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一张图像,我想在 UITableViewCell
中使用提供 UIImageView
的 UITableViewCellStyleSubtitle
样式和两行文本,加上一个可选的附件 View 。
但是,当我将 UIImageView
的内容模式设置为 UIViewContentModeScaleAspectFit
或 UIViewContentModeScaleAspectFill
之一时,它似乎没有任何区别。这两种内容模式都只是显示整个图像,将文本向右移动以为图像腾出空间。
有没有人举例说明这些在实践中有何不同?文档说:
UIViewContentModeScaleAspectFit:
Scales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.
UIViewContentModeScaleAspectFill:
Scales the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.
但这些内容模式似乎并不像宣传的那样表现。
编辑:我正在运行 SDK iOS 4。
最佳答案
我遇到了同样的问题。好像苹果文档有点欠缺。
我通过在互联网上搜索找到了答案。 http://www.iphonedevsdk.com/forum/iphone-sdk-development/2973-crop-image.html
基本上,
img1.contentMode = UIViewContentModeScaleAspectFill;
img1.clipsToBounds = YES;
如果你想让它更花哨一点,看看这篇文章: UIImageView change Width and Height
关于iphone - iOS SDK UIViewContentModeScaleAspectFit 与 UIViewContentModeScaleAspectFill,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3182649/
我在 UICollectionViewCell 中使用 UIImageView。我已将 contentMode 设置为 UIViewContentModeScaleAspectFill 并将 Clip
我正在尝试使用 UIImageView 以固定大小 (100x100) 绘制一些缩略图。我已将 ImageView 的帧大小设置为 100x100,并将 contentMode 设置为 UIViewC
目前,此设置(例如在 UIImageView 上)会将 UIImage 的中心保持在 UIImageView 的中心,并“裁剪”超出的边缘两边的边界相等。 有办法改变这种情况吗? 例如,如果我希望它使
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在尝试以与照片应用程序相同的方式在 iPhone 上显示图像。它似乎能够根据适合图像的内容动态选择 UIViewContentModeScaleAspectFit 或 UIViewContentM
假设我有一个具有大框架的 UIImage。 我把这个 UIImage 放到一个 UIImageView *myImageView; 我将 myImageView 的内容模式设置为 UIViewCont
使用下面的代码,我已经将背景图像添加到 UINavigationController( View ,而不是导航栏)并且我试图缩放图像以填充 View ,因为我不知道用户的设备和方向。 (注意:我不想创
我想根据我的指南使用相机拍摄照片。当我将它保存到一个按钮中并调整宽高比时,图像聚焦在图像的中间部分。如果我将指南居中,这会很好。但我希望指南更高。因此,我想将图像移低。这是代码 [personPhot
我有一张图像,我想在 UITableViewCell 中使用提供 UIImageView 的 UITableViewCellStyleSubtitle 样式和两行文本,加上一个可选的附件 View 。
我的应用程序中有一个 UIButton,在这里我给它一张图片而不是文本,因为它作为缩略图按钮提供服务,在被点击时会显示完整的图片。 我看到了this answer这似乎是公认的实现方式,但是对于小于按
我在玩 UIImageView 的 contentMode 属性。 当我将其设置为 UIViewContentModeScaleAspectFill 时,图像会缩放以适合屏幕。它居中。所以图片的左右(
我是一名优秀的程序员,十分优秀!