Skip to content

Commit

Permalink
Do not enforce label text alignment based off effective user interfac…
Browse files Browse the repository at this point in the history
…e layout direction (#5475)

The problem:

We were enforcing label text alignment based off effective user interface layout direction.
As a result, if the system language was English and you created an Arabic label (with its textAlignment set to Right) the label would ultimately end up with a textAlignment of Left.

The solution:

Don't set textAlignment from within the cell. Leave it to the client.

Closes #5472.

Before:
![simulator screen shot - iphone x - 2018-10-22 at 16 23 26](https://user-images.githubusercontent.com/8020010/47317932-b50eb800-d618-11e8-999d-19aad687dbf2.png)

After:
![simulator screen shot - iphone x - 2018-10-22 at 16 23 58](https://user-images.githubusercontent.com/8020010/47317931-b50eb800-d618-11e8-9ae1-c70d4af7f3ae.png)
  • Loading branch information
andrewoverton committed Oct 23, 2018
1 parent b47b889 commit 14f66dc
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions components/List/src/MDCSelfSizingStereoCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ - (void)layoutSubviews {
self.leadingImageView.frame = layout.leadingImageViewFrame;
self.trailingImageView.frame = layout.trailingImageViewFrame;
if (self.mdf_effectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
self.titleLabel.textAlignment = NSTextAlignmentRight;
self.detailLabel.textAlignment = NSTextAlignmentRight;
self.leadingImageView.frame =
MDFRectFlippedHorizontally(self.leadingImageView.frame, layout.cellWidth);
self.trailingImageView.frame =
Expand All @@ -135,9 +133,6 @@ - (void)layoutSubviews {
MDFRectFlippedHorizontally(self.titleLabel.frame, self.textContainer.frame.size.width);
self.detailLabel.frame =
MDFRectFlippedHorizontally(self.detailLabel.frame, self.textContainer.frame.size.width);
} else {
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.detailLabel.textAlignment = NSTextAlignmentLeft;
}
}

Expand Down

0 comments on commit 14f66dc

Please sign in to comment.