juanpablofernandez / SwiftyOnboard

A swifty iOS framework that allows developers to create beautiful onboarding experiences.
MIT License
1.25k stars 105 forks source link

RTL (right-to-left) languages support #42

Open andrey-lisovskiy opened 5 years ago

andrey-lisovskiy commented 5 years ago

Does SwiftyOnboard support right-to-left languages, so user can swipe from left to right?

dtashkandi commented 4 years ago

same issue

dtashkandi commented 4 years ago

@andrey-lisovskiy install the framework manually (as described in the README), then in SwiftyOnboard class add this line open var rtl: Bool = false. Then go to the function fileprivate func setUpPages() and before the line containerView.addSubview(view) add the following: if self.rtl { containerView.transform = CGAffineTransform(rotationAngle: .pi) view.transform = CGAffineTransform(rotationAngle: .pi) }

What this does is first rotate the containerView, which is essentially the scrollView by 180 degrees so the scroll direction would go from right-to-left. Rotating the containerView would rotate your view as well so you want to rotate the view again by 180 to reverse the first rotation.

I hope that was clear.

dtashkandi commented 4 years ago

@andrey-lisovskiy actually, I just found a PR (#44) that solves this issue the same way. You can take a look at that. The difference is that in my proposed solution I add a variable to determine which direction I want to scroll in because I'm localizing my app for English and Arabic, and I want the scroll to do both directions.