Last active
June 9, 2016 11:21
-
-
Save amratab/c4b77877b5a06be9437c7de757da0578 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
https://www.natashatherobot.com/ios-autolayout-scrollview/ | |
class ScrollTestViewController: UIViewController { | |
@IBOutlet weak var contentView: UIView! | |
@IBOutlet weak var scrollView: UIScrollView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let containerViewBounds = contentView.bounds | |
scrollView.contentSize=CGSizeMake(containerViewBounds.size.height + 20,containerViewBounds.size.width + 20) | |
// Do any additional setup after loading the view. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
override func viewDidLayoutSubviews() | |
{ | |
let scrollViewBounds = scrollView.bounds | |
print(scrollViewBounds.size.width) | |
print(scrollViewBounds.size.height) | |
let containerViewBounds = contentView.bounds | |
print(containerViewBounds.size.width) | |
print(containerViewBounds.size.height) | |
// var scrollViewInsets = UIEdgeInsetsZero | |
// scrollViewInsets.top = scrollViewBounds.size.height/2.0; | |
// scrollViewInsets.top -= contentView.bounds.size.height/2.0; | |
// | |
// scrollViewInsets.bottom = scrollViewBounds.size.height/2.0 | |
// scrollViewInsets.bottom -= contentView.bounds.size.height/2.0; | |
// scrollViewInsets.bottom += 1 | |
// | |
// scrollView.contentInset = scrollViewInsets | |
scrollView.contentSize=CGSizeMake(1000,1000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment