0

I have created a UIScrollView and added UILabels and UIButtons. I then have created a UIImageView and added it to the my UIScrollView. I have used the following code to set the UIImageView to the background of my UIScrollView.

        let paperImageView = UIImageView(image: UIImage(named: "White Notebook Paper.png"))
        paperImageView.frame = CGRect(x: -60, y: -60, width: UIScreen.main.bounds.width + 60, height: currentY + 60)
        scrollView.addSubview(paperImageView)
        scrollView.sendSubview(toBack: paperImageView)

As you can see in the following screenshot, by UIImageView is distorted.

enter image description here

The background image supposed to look like notebook paper. As you can see, the spacing of the lines becomes wider the lower you go in the UIScrollView. Thanks for taking the time to share your thoughts.

5
  • try changing content mode of imageview Commented Nov 22, 2016 at 1:31
  • @Jay Taylor , your image is average distribution of these lines? Commented Nov 22, 2016 at 2:30
  • @Jay Taylor , currentY is how much? Commented Nov 22, 2016 at 2:49
  • @Vinodh Yep!! That did the trick!! Thanks!! Commented Nov 22, 2016 at 2:51
  • @aircraft You are correct with the average distribution. I just forgot the address the content mode. Thanks!! Commented Nov 22, 2016 at 2:52

1 Answer 1

1

I forgot to change the content mode of the image view.

paperImageView.contentMode = .scaleAspectFill
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.