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

I created xAxis to show my characters in the center of the screen because I am creating a Puzzle Word project, now my problem is my characters showing on the left how to convert from left to right ??? because my characters are Arab.

For example, my word is (London), but show me the inversion (nodnoL). This example is in English. So how to fix this problem for converting to the right or left side?

This code of mine:

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))

    .....
}

      

+1


source to share





All Articles