Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UITableView direction to Right-to-Left

I develop an iOS application and my native language is Persian (a Right-to-Left language). How can I change UITableView direction to right-to-left in iOS programming?

A UITableView with RTL direction has:

  • Icons are at right
  • TableCell detail and button are at left
  • TableView header and footer are right-aligned

like this :

enter image description here

Is there any UI or programming way to do this?

like image 518
Omid Golparvar Avatar asked Jun 26 '16 06:06

Omid Golparvar


People also ask

How do I change the Tableview style in Swift?

You can't change the tableview style dinamically, you have to do it in your xib file or storyboard if you have one. If you don't use a storyboard or a xib, and prefer to create the tableview programmatically, specify the style while creating the tableview using the - initWithFrame:style: method.

How do I populate UITableView?

There are two main base ways to populate a tableview. The more popular is through Interface Building, using a prototype cell UI object. The other is strictly through code when you don't need a prototype cell from Interface Builder.

What is UITableView in Swift?

A view that presents data using rows in a single column.


1 Answers

Try this on Swift 3

tableView.semanticContentAttribute = .forceRightToLeft

or in StoryBoard Cell properties (Semantic dropdown) select "Force Right-To-Left"

enter image description here

like image 74
Sedat Y Avatar answered Sep 18 '22 16:09

Sedat Y