Illep
Illep

Reputation: 16849

Adding a background image to UIScrollView

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

The image has a fixed size like 320X460. But when the scroll view scrolls further down i can see white colour areas on the scroll view.

How could i prevent this ?

I tried adding the image to the view, and making the scrollview background as clearColor, but it doesn't work.

[scrollView addSubView:imageView];

self.view = scrollview;

[scrollview setBackgroundColor:[UIColor clearColor]];

Upvotes: 9

Views: 16807

Answers (2)

TigerCoding
TigerCoding

Reputation: 8720

If you don't want to tile an image, insert the image view:

[webView insertSubview:backgroundImage atIndex:0];

Then set it's size to match the webView at creation or in viewWillLayoutSubviews.

Upvotes: 1

commanda
commanda

Reputation: 4881

Try setting a tileable image as your background color.

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

Upvotes: 31

Related Questions