Adding a Background Image to UIScrollView

I have a UIScrollView added to a UIView. Now I have added the background image to scrollVIew.

The image has a fixed size, for example 320X460. But when the scroll scrolls further, I see areas of white color in the scroll view.

How can I prevent this?

I tried adding an image to the view and making the scrollview background as clearColor, but it does not work.

 [scrollView addSubView:imageView]; self.view = scrollview; [scrollview setBackgroundColor:[UIColor clearColor]]; 
+6
source share
2 answers

Try setting the color image as the background color.

 scrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tileableImage.png"]]; 
+28
source

If you do not want to split the image, insert the image:

 [webView insertSubview:backgroundImage atIndex:0]; 

Then set the size to match the WebView when creating or in viewWillLayoutSubviews.

+1
source

Source: https://habr.com/ru/post/908635/


All Articles