Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView with background image

I want to have a background image behind a UIScrollView area. That part's easy. The issue I'm running into is I don't want the image to move. I want it to fill the screen and then the scrolling just happens over that without effecting the image in anyway.

I've looked through lots of other postings on similar topics, but can't seem to get anything to work.

When I do the following, the background scrolls:

CGRect fullScreenRect = [[UIScreen mainScreen] applicationFrame];
UISCrollView *scrollView = [[UIScrollView alloc] initWithFrame:fullScreenRect];
scrollView.backgroundColor = [UIColor clearColor];
UIImageView *bkg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img"]];
[scrollView addSubview:bkg];
like image 857
johannix Avatar asked May 31 '12 00:05

johannix


1 Answers

Put the image in a UIImageView and place it behind the UIScrollView. Set the UIScrollView's color to 100% transparency ([UIColor clearColor]).

like image 187
nhahtdh Avatar answered Oct 15 '22 15:10

nhahtdh