gpt4 book ai didi

iphone - iOS SDK UIViewContentModeScaleAspectFit 与 UIViewContentModeScaleAspectFill

转载 作者:太空狗 更新时间:2023-10-30 03:16:20 31 4
gpt4 key购买 nike

我有一张图像,我想在 UITableViewCell 中使用提供 UIImageViewUITableViewCellStyleSubtitle 样式和两行文本,加上一个可选的附件 View 。

但是,当我将 UIImageView 的内容模式设置为 UIViewContentModeScaleAspectFitUIViewContentModeScaleAspectFill 之一时,它似乎没有任何区别。这两种内容模式都只是显示整个图像,将文本向右移动以为图像腾出空间。

有没有人举例说明这些在实践中有何不同?文档说:

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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com