ios - 将contentMode设置为UIViewContentModeScaleAspectFit时,如何设置UIImageView左对齐或右对齐?

标签 ios uiview uiimageview uiimage

我想在 UIImageView 中使用 UIViewContentModeScaleAspectFit 时控制图像对齐。

enter image description here

例如,我在一个 View 中有两个 UIImageView,如上。这两个 UIImageView 的 contentMode 是 UIViewContentModeScaleAspectFit。现在我想设置图片3右对齐,图片4左对齐,这样两张图片就可以放在一起了。

我尝试将 contentMode 设置为 UIViewContentModeScaleAspect|UIViewContentModeLeft,但这让事情变得更糟。

如有任何建议,我们将不胜感激。

最佳答案

最后,我找到了UIImageViewAligned可以解决的项目。

感谢@Marchy,还有swift版本UIImageViewAlignedSwift

关于ios - 将contentMode设置为UIViewContentModeScaleAspectFit时,如何设置UIImageView左对齐或右对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18626816/

相关文章:

ios - 将图像从S3存储桶加载到uiTableView

ios - touchesBegan 和 touchesMoved 没有在 UIView 上触发

ios - UIView 背景颜色和顶部透明png

ios - UIImageView 自动从 self.view 中移除自身

ios - 为什么高度相关的方法放在 UITableViewDelegate 中,而不是放在 UITableViewDataSource 中

ios - 使用多个字符串创建 onDoneBlock

ios - 为什么 UIViewController 在 UINavigationBar 下扩展,而 UITableViewController 没有?

ios - UICollectionView 单元格中的 UIImageView 不显示

swift - 限制边距在 Xcode 上无法正常工作

javascript - 适用于 Android、iOS 和 Windows 平板电脑的 Cordova 滑动事件检测选项