Skip to content

Let imageView scroll #1

@onmyway133

Description

@onmyway133

Thanks for the code, you explain better than the original blog :D

With the current implementation, the imageView always pins to the top.
Now we have 2 top constraints from the imageView to the TopLayoutGuide (1 with equal, priority 999 and 1 with less than, priority 1000), let call them C1 and C2

This would make it scroll with the scrollView as well

func scrollViewDidScroll(scrollView: UIScrollView) {
        let y = scrollView.contentOffset.y

        if y > 0 {
            c1.constant = -y
            c2.constant = -y
        } else {
            c1.constant = 0
            c2.constant = 0
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions