Last active
August 29, 2015 14:17
-
-
Save tianchu/b0b9d92cdda66fa37451 to your computer and use it in GitHub Desktop.
ScrollView + AutoLayout using Swift and PureLayout
This file contains hidden or 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
class MyViewController: UIViewController { | |
var scrollView = UIScrollView.newAutoLayoutView() | |
var contentView = UIView.newAutoLayoutView() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.addSubview(scrollView) | |
scrollView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero) | |
scrollView.addSubview(contentView) | |
contentView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero) | |
contentView.autoMatchDimension(.Width, toDimension: .Width, ofView: view) | |
var subview1 = UILabel() | |
subview1.text = "Test" | |
contentView.addSubview(subview1) | |
subview1.autoPinEdgeToSuperviewEdge(.Top, withInset: 20) | |
subview1.autoPinEdgeToSuperviewEdge(.Leading, withInset: 20) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @tianchu! I'm trying to do something like this with your code, but it won't scroll. Any suggestions?