Closed bianxiang closed 7 years ago
Hey there @bianxiang, I ran into this issue as well when using IB. I noticed the content offset was changing after loading the view. I added the following line to layoutSubviews() in the placeholder view class:
setContentOffset(CGPoint(x: 0, y: 0), animated: false)
So the updated method looks like:
open override func layoutSubviews() {
super.layoutSubviews()
setContentOffset(CGPoint(x: 0, y: 0), animated: false)
placeholderLabel.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2.0
}
I hope that helps!
Thanks @bianxiang @PhiltheHen, if the scroll view is the first child view of the view controller's view and the property automaticallyAdjustsScrollViewInsets
of the view controller sets to true
which can cause the problem.
There are two ways to solve this problem:
automaticallyAdjustsScrollViewInsets
to false
I want to set placeholder on top.