romansorochak / ParallaxHeader

Simple way to add parallax header to UIScrollView/UITableView written in Swift.
MIT License
1.03k stars 131 forks source link

ParallaxHeader and safeAreaLayoutGuide #58

Open kunass2 opened 3 months ago

kunass2 commented 3 months ago

I would like to stick it to the top ov the screen. Is it possible?

As you can see on the image it should be constrained to the top of the screen, but it is not. Why?

IMG_3488 IMG_3489 Screenshot 2024-06-28 at 12 48 58

This is how i defined it in code:

    private let imageView: UIImageView = {
        let view = UIImageView()
        view.contentMode = .scaleAspectFill
        return view
    }()

    private lazy var scrollView: UIScrollView = {
        let view = UIScrollView()
        view.showsVerticalScrollIndicator = false
        view.bounces = true
        view.backgroundColor = .clear
        view.parallaxHeader.view = imageView
        view.parallaxHeader.mode = .centerFill
        view.parallaxHeader.height = 400
        view.parallaxHeader.minimumHeight = 100
        return view
    }()

        addSubview(scrollView)
        scrollView.snp.makeConstraints { maker in
            maker.leading.trailing.top.equalToSuperview()
            maker.bottom.equalTo(safeAreaLayoutGuide)
        }