0

I have a UIView located a UIScrollView on it.

let curtainView = UIScrollView ()
curtainView.snp.makeConstraints {make in
            make.edges.equalToSuperview ()
}

And also UIView.

let someView = UIView ()
someView.snp.makeConstraints {make in
        make.top.equalToSuperview (). offset (10)
        make.leading.trailing.equalToSuperview (). inset (10)
}

Objective: Set contentInset for UIScrollView depending on UIView visibility. UIView's visibility changes through RxSwift. I am doing the following

override func layoutSubviews () {
        super.layoutSubviews ()
        curtainView.contentInset.top = someView.isHidden? self.frame.minY: someView.frame.maxY
    }

The layoutSubviews method is called multiple times:

1.curtainView.contentInset.top == 0
2.curtainView.contentInset.top == 0
3.curtainView.contentInset.top == 30

However, visually the contentInset of someView remains unchanged. Only after the swipe does the curtain set the correct indents. I do not have permission to add images, please see them on a third-party resource: https://youtu.be/LecHmLd9HP4

0 Answers0