I got question about UIScrollview.
The story is I have a UIView named ChartsView which I re-draw it myself by override method drawRec
swift (2.0)
@IBOutlet weak var btnLatestButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let height = btnLatestButton.frame.size.height
let pos = btnLatestButton.frame.origin.y
let sizeOfContent = height + pos + 10
scrollview.contentSize.height = sizeOfContent
}
Above ofcourse is when you just have a fixed amount of views on your scrollview. IOS Rocks method is available but was not good for me, created more space then I needed.
let lastView : UIView! = scrollview.subviews.last
let height = lastView.frame.size.height
let pos = lastView.frame.origin.y
let sizeOfContent = height + pos + 10
scrollview.contentSize.height = sizeOfContent