Skip to content

Implementations of trailingToSuperview and leadingToSuperview only work correct only for Left-to-Right languages / layout.ย #95

@therohansanap

Description

@therohansanap

What layout do I expect?

I want my signupButton to have it's trailing edge 20 points before safeAreaLayoutGuide.centerXAnchor. Similarly, I want my loginButton to have its leading edge 20 points after safeAreaLayoutGuide.centerXAnchor. Below image displays the layout in desired state:
LTR
Left-to-Right Layout ๐Ÿ‘†๐Ÿพ
RTL-correct
Right-to-Left Layout ๐Ÿ‘†๐Ÿพ

What does my code looks like?

let signupButton = UIButton(type: .system)
signupButton.setTitle("Signup", for: .normal)
view.addSubview(signupButton)
signupButton.bottomToSuperview(offset: -50)
signupButton.trailingToSuperview(view.safeAreaLayoutGuide.centerXAnchor, offset: 20)

let loginButton = UIButton(type: .system)
loginButton.setTitle("Login", for: .normal)
view.addSubview(loginButton)
loginButton.bottomToSuperview(offset: -50)
loginButton.leadingToSuperview(view.safeAreaLayoutGuide.centerXAnchor, offset: 20)

What output do I get with above code?

Below are the screenshots of my output:
LTR
Left-to-Right Layout ๐Ÿ‘†๐Ÿพ
RTL-bug
Right-to-Left Layout ๐Ÿ‘†๐Ÿพ

The problem

It looks like the way superview methods are implemented, they work correct only for Left-to-Right language / layout direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions