Created
February 4, 2019 16:59
-
-
Save crayment/8d9e9b97796b42e98d1d0a9ac5622bc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PlaygroundSupport | |
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.view.backgroundColor = .white | |
let stackView = UIStackView() | |
stackView.translatesAutoresizingMaskIntoConstraints = false | |
stackView.alignment = .center | |
stackView.axis = .vertical | |
stackView.spacing = 20 | |
let label1 = UILabel() | |
label1.text = "مرحبًا. يرجى تسجيل الدخول أدناه للوصول إلى الدورات التدريبية الخاصة بك." | |
label1.numberOfLines = 0 | |
stackView.addArrangedSubview(label1) | |
let textField = UITextField() | |
textField.borderStyle = .roundedRect | |
textField.placeholder = "اسم المستخدم" | |
stackView.addArrangedSubview(textField) | |
stackView.addArrangedSubview(UISwitch()) | |
self.view.addSubview(stackView) | |
NSLayoutConstraint.activate([ | |
stackView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 20), | |
stackView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -20), | |
stackView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 20), | |
textField.widthAnchor.constraint(equalTo: stackView.widthAnchor), | |
textField.heightAnchor.constraint(equalToConstant: 44) | |
]) | |
} | |
} | |
let child = ViewController() | |
let container = UIViewController() | |
container.view.addSubview(child.view) | |
child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
child.view.frame = container.view.bounds | |
container.addChild(child) | |
container.setOverrideTraitCollection( | |
UITraitCollection(layoutDirection: .rightToLeft), | |
// UITraitCollection(layoutDirection: .leftToRight), | |
forChild: child | |
) | |
PlaygroundPage.current.liveView = container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment