Closed VasilisLule closed 5 years ago
Like that:
class IntroViewController: BaseViewController {
fileprivate let rootFlexContainer = UIView()
init(pageType: PageType) {
super.init()
title = pageType.text
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
let imageView = UIImageView(image: UIImage(named: "flexlayout-logo"))
let segmentedControl = UISegmentedControl(items: ["Intro", "FlexLayout", "PinLayout"])
segmentedControl.selectedSegmentIndex = 0
let label = UILabel()
label.text = "Flexbox layouting is simple, powerfull and fast.\n\nFlexLayout syntax is concise and chainable."
label.numberOfLines = 0
let bottomLabel = UILabel()
bottomLabel.text = "FlexLayout/yoga is incredibly fast, its even faster than manual layout."
bottomLabel.numberOfLines = 0
rootFlexContainer.flex.direction(.column).padding(12).define { (flex) in
flex.addItem().direction(.row).define { (flex) in
flex.addItem(imageView).width(100).aspectRatio(of: imageView)
flex.addItem().direction(.column).paddingLeft(12).grow(1).shrink(1).define { (flex) in
flex.addItem(segmentedControl).marginBottom(12).grow(1)
flex.addItem(label)
}
}
flex.addItem().height(1).marginTop(12).backgroundColor(.lightGray)
flex.addItem(bottomLabel).marginTop(12)
}
view.addSubview(rootFlexContainer)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// Layout the flexbox container using PinLayout
// NOTE: Could be also layouted by setting directly rootFlexContainer.frame
rootFlexContainer.pin.top().horizontally().margin(view.pin.safeArea)
// Then let the flexbox container layout itself
rootFlexContainer.flex.layout(mode: .adjustHeight)
}
}
You are the best!
30 Οκτ 2019, 4:09 μμ, ο χρήστης «Luc Dion notifications@github.com» έγραψε:
Like that:
class IntroViewController: BaseViewController { fileprivate let rootFlexContainer = UIView()
init(pageType: PageType) { super.init() title = pageType.text } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white let imageView = UIImageView(image: UIImage(named: "flexlayout-logo")) let segmentedControl = UISegmentedControl(items: ["Intro", "FlexLayout", "PinLayout"]) segmentedControl.selectedSegmentIndex = 0 let label = UILabel() label.text = "Flexbox layouting is simple, powerfull and fast.\n\nFlexLayout syntax is concise and chainable." label.numberOfLines = 0 let bottomLabel = UILabel() bottomLabel.text = "FlexLayout/yoga is incredibly fast, its even faster than manual layout." bottomLabel.numberOfLines = 0 rootFlexContainer.flex.direction(.column).padding(12).define { (flex) in flex.addItem().direction(.row).define { (flex) in flex.addItem(imageView).width(100).aspectRatio(of: imageView) flex.addItem().direction(.column).paddingLeft(12).grow(1).shrink(1).define { (flex) in flex.addItem(segmentedControl).marginBottom(12).grow(1) flex.addItem(label) } } flex.addItem().height(1).marginTop(12).backgroundColor(.lightGray) flex.addItem(bottomLabel).marginTop(12) } view.addSubview(rootFlexContainer) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() // Layout the flexbox container using PinLayout // NOTE: Could be also layouted by setting directly rootFlexContainer.frame rootFlexContainer.pin.top().horizontally().margin(view.pin.safeArea) // Then let the flexbox container layout itself rootFlexContainer.flex.layout(mode: .adjustHeight) }
} — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/layoutBox/FlexLayout/issues/148?email_source=notifications&email_token=ANRXGG6FLPKNGRJZH73DDQDQRGISZA5CNFSM4JGWUKZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECUKFRY#issuecomment-547922631, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANRXGGYGOIJRLCLFBN7APVDQRGISZANCNFSM4JGWUKZA.
Hello, I am trying to run the application without using the IntroView. how suppose i can make the example run directly in the viewController