Flip UIImageViews for Right to Left Languages

后端 未结 7 1479
悲&欢浪女
悲&欢浪女 2021-02-13 02:31

iOS automatically flips the entire ViewController when using a RTL language like Arabic and does a great job with most of the layout, especially text. The default b

7条回答
  •  无人共我
    2021-02-13 03:00

    We can use imageFlippedForRightToLeftLayoutDirection which returns flipped image if current language is RTL(right to left). i.e

    Objective-c

    UIImage * flippedImage = [[UIImage imageNamed:@"imageName"] imageFlippedForRightToLeftLayoutDirection];
    

    Swift 3

    let flippedImage = UIImage(named: "imageName")?.imageFlippedForRightToLeftLayoutDirection()
    

    Source: Apple Docs

提交回复
热议问题