如何设置的UIScrollView的背景是透明的? [英] How do I set the background of UIScrollView to be transparent?

查看:140
本文介绍了如何设置的UIScrollView的背景是透明的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最终会喜欢做是有我滚动视图内容滚动(在滚动视图控件),且有一个静态的背景(壁纸图像)。

What i ultimately would LOVE to do is having my scroll view contents scrolling (in the scroll view control), and have a static background (a wallpaper image).

我试过事物的组合,其中没有真正得到什么即时寻找,甚至还没有接近真。

I've tried a combination of things, none of which really yields what im looking for, not even close really.

有没有人尝试过​​呢?

Has anybody attempted this before?

推荐答案

这其实很容易,一个的UIScrollView 的UIView 所以你只需要设置的backgroundColor 属性:

This is actually very easy, a UIScrollView inherits from a UIView so you just need to set the backgroundColor property:

aScrollView.backgroundColor = [UIColor clearColor];

code的上述行设置背景透明,这样就可以看到通过任何你想放后面。还要注意的是你应该做同样的事情,你的滚动视图里面放子的观点 - 这些观点也应该有一个透明背景颜色

The above line of code sets the background to transparent so you can see through to whatever you want to put behind. Note also that you should do the same thing to the sub-views that you put inside the scroll-view - those views should also have a transparent background colour.

如果你想有一个静态图像,使用的模式如下code线。这比将重复/平铺在屏幕上,或全屏图像纹理图像小,所以你看不到任何重复。

If you want a static image, use a pattern as in the line of code below. This can be a texture image smaller than the screen that will be repeated/tiled, or a full-screen image so you don't see any repeats.

aScrollView.backgroundColor = [UIColor colorWithPatternImage:anImage];

这篇关于如何设置的UIScrollView的背景是透明的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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