Thursday, July 27, 2017

table cell views are not right aligned

Leave a Comment

I am trying to right-align my table cells.

simulator

I have set 'Semantic' property to 'Force Right-to-Left' value through the whole visual tree.

Desired layout:

Desired state

Visual tree:

Visual tree

There aren't any visual definitions in code...

EDIT:

After @dirtydanee suggestion:

trailed

6 Answers

Answers 1

Stack view configuration

For your stack view you should have alignment set to Leading to make it start at the leading position for your language, which is the right most side for you. Then you set Semantic to Force Right-to-Left.

It is important that you have tied the stack views edges to it's container's edges, so that the stack view will size to it's container. It is also important that you let the labels have dynamic size. Both of these conditions seems to be met in your code, although it is not entirely clear.

Answers 2

Just do following thing to assign text right side in tableviewCell

  • Step 1: Select view in contect View cell in StoryBoard

  • Step 2: Alignment text to right side.

Description image

Answers 3

It seems that your constraints are wrong.

Constrain your labels to the right and align their text to the right.

Here is an example:

enter image description here

And running on simulator:

enter image description here

Answers 4

If you use leading and trailing constraints to layout your UILabel elements, everything gets switched automagically to the right site if using a Right-To-Left language. There is no need to change the NSTextAlignment (.natural is default and the one you need) or the UISemanticContentAttribute of the UILabel. enter image description here


Be aware that you need to have at least one RTL language added to your project localizations:

enter image description here


When the language of your iPhone / iPad is set to Hebrew everything should work as expected:

enter image description here

Answers 5

It is also depend on Your Device Selected Lang.

You can try to use left instead of leading and use right instead of trailing

Answers 6

I tried a demo and i think what you need to do is set semantic for each label separately

go to perekSourcelabel set semantic right-to-left then do same for header label

dont set semantic for your stack view or the whole perekTableViewcell

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment