带有背景图像的 UIScrollView [英] UIScrollView with background image

查看:64
本文介绍了带有背景图像的 UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 UIScrollView 区域后面有一个背景图像.那部分很容易.我遇到的问题是我不希望图像移动.我希望它填满屏幕,然后滚动就发生了,无论如何都不影响图像.

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

推荐答案

将图像放入 UIImageView 并将其放在 UIScrollView 后面.将 UIScrollView 的颜色设置为 100% 透明度([UIColor clearColor]).

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

这篇关于带有背景图像的 UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆