UIScrollView with background image

2019-05-06 18:18发布

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];

1条回答
爷的心禁止访问
2楼-- · 2019-05-06 18:43

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

查看更多
登录 后发表回答