On the prime of scrollView, I’ve an imageView and i need it to be on the prime of the display however it doesn’t matter what i attempted i couldn’t discover a solution to put it on the highest of the display. It begins below the statusBar. Right here is how is it look:
and that is what i need:
Listed here are the constraints:
NSLayoutConstraint.activate([
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor),
imageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
imageView.topAnchor.constraint(equalTo: contentView.topAnchor),
imageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
imageView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.45), ]) }
I attempted this however did not repair:
scrollView.contentInsetAdjustmentBehavior = .by no means
there may be one resolution that labored nevertheless it isnt the very best strategy i consider:
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, fixed: -130),
Once I add a relentless to the highest anchor of the scrollView, it resolves the problem. Nevertheless, on different screens comparable to iPads or iPhone X, I want to regulate this fixed accordingly. I am unsure if calculating the peak of the standing bar after which dynamically adjusting the constraints is the the very best strategy. I really feel like there have to be a neater approach.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?