UIScrollView with background image

自古美人都是妖i 提交于 2019-12-22 06:10:05

问题


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:


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



来源:https://stackoverflow.com/questions/10826117/uiscrollview-with-background-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!