Can anyone explain why the orange square is not at the 0 point, and i can still scroll my scroll view up and down by the 20 pixels?
import UIKit
class MessageVC: UIViewController, UIScrollViewDelegate {
let scrollView = UIScrollView()
let messageHolder = MessageHolderVC()
let messageSender = MessageSenderVC()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.whiteColor()
scrollView.frame = CGRectMake(0, 1, self.view.frame.width, self.view.frame.height - 2)
scrollView.backgroundColor = UIColor.redColor()
scrollView.pagingEnabled = true
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 2, scrollView.frame.size.height)
scrollView.bounces = false
self.view.addSubview(scrollView)
messageHolder.view.frame = CGRectMake(0, 0, 20, 20)
scrollView.addSubview(messageHolder.view)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/