Swift 3- Convert characters side from right to left or left to right

霸气de小男生 提交于 2019-12-24 06:05:55

问题


I created xAxis to show my characters in the center of the screen because I'm creating Puzzle Word project, now my issue is my characters showing from left, how to convert from left to right ?? because my characters are Arabic.

For example my word is (London) but show me inversion (nodnoL) This example is in English. So how to fix this issue convert to right side or left side ??

This my code :

for (indexTar, tar) in data.ans.characters.enumerated() {

    let x : CGFloat = (width / 2) - (totalWidth / 2)
    let xx : CGFloat = (CGFloat(indexTar) * targetWidth) + (CGFloat(indexTar) * 5) + 20
    var xAxis : CGFloat = (x + xx)                    
    let targetLabel = UILabel(frame: CGRect(x: xAxis, y: yAxis, width: targetWidth, height: 5.0))

    .....
}

来源:https://stackoverflow.com/questions/45242109/swift-3-convert-characters-side-from-right-to-left-or-left-to-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!