ios - 用于本地化的 UITableView 单元格中的镜像

标签 ios swift uitableview

images in cells are not flipped

我需要翻转 UITableview 单元格中的箭头图像。我正在尝试使用 flipsForRightToLeftLayoutDirection 但它没有产生镜像效果。

if #available(iOS 10.0, *) {
    cell.imageViewArrow.image?.withHorizontallyFlippedOrientation()
} 
else {
    cell.imageViewArrow.image =   UIImage(cgImage: (cell.imageViewArrow.image?.cgImage!)!, scale:(cell.imageViewArrow.image?.scale)! , orientation: UIImageOrientation.upMirrored)
    // Fallback on earlier versions
}

最佳答案

您没有将图像设置为任何内容。用这个替换你的代码:

cell.imageViewArrow.image = cell.imageViewArrow.image?.withHorizontallyFlippedOrientation()

但是,建议仅在语言为RTL 时设置翻转图像。为此,将图像设置为 imageFlippedForRightToLeftLayoutDirection() 的返回值:

cell.imageViewArrow.image = cell.imageViewArrow.image?.imageFlippedForRightToLeftLayoutDirection()

关于ios - 用于本地化的 UITableView 单元格中的镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50154717/

相关文章:

ios - 服务器端 swift Vapor - 重新定义模块错误

ios - 快速回历(伊斯兰)日历

ios - MPMoviePlayerController 的角半径

ios - 在 XCTest 用例中处理 CLLocationManager 授权请求

ios - 如何删除单元格开头和文本之间的空格?

ios - 具有核心数据和非核心数据源的 UITableView

ios - 如何在项目中间使用显示 View Controller 而不是初始 View Controller

ios - bundle ID未列出应用商店连接新应用列表(Xcode 11.4.1)

ios - 如何在 AudioKit 中渲染和导出音频?

ios - 带有图像的 UITableView 在滚动时会暂时显示错误的图像