UIScrollView - cant get my background to be transparent

已查看 898 次
跳至第一个未读帖子

Bob

未读,
2009年4月7日 13:20:232009/4/7
收件人 iPhone SDK Development
Im manually adding a UIScrollView to my View, however
I cant seem to get it to show my background of the view.

Ive tried setting clearColor, initWithRed, green, blue, alpha 0.0
and :

UIImage *img = [[UIImage alloc] initWithContentsOfFile:[g_utils
dbPath:BACK_IMG]];
textView.layer.contents = (CALayer *)img.CGImage;

Nothing seems to work. Has anyone gotten this to work
programmatically?
Or do I have to use IB to do it?

Im adding about 60 labels to my UIScrollView so doing it in IB is what
I was trying to avoid.

Thanks

Brad Larson

未读,
2009年4月8日 13:57:392009/4/8
收件人 iphonesdkd...@googlegroups.com


By default, UIScrollView is transparent and shows the content of the
view below it or its hosting view (although it won't let touch events
pass through). You might want to check that your subview(s) of the
UIScrollView has its backgroundColor set to [UIColor clearColor].

For example, if you watch the video on my page here: http://www.sunsetlakesoftware.com/picubed
, you'll see that the equation I display is hosted within a
transparent UIScrollView (this is most visible at about the midpoint
of the video). I'm also rendering a lot of text, although in my case
it's all generated from CALayers. This is all generated
programmatically, with no XIBs in the project at all. I have one
subview added to the UIScrollView, the view hosting the equation, and
it has a clearColor background.

I have no idea what's going on with your textView there. Why are you
setting its layer's content manually? Why are you typecasting the
CGImage to a CALayer pointer? Something seems odd there, but all of
that is completely unrelated to your scroll view.

______________________
Brad Larson, Ph.D.
Sunset Lake Software
http://www.sunsetlakesoftware.com

Bob

未读,
2009年4月10日 09:19:462009/4/10
收件人 iPhone SDK Development
Thanks Brad, turns out it was my error.
Indeed it was the content I was putting on top of my scrollview
that was not transparent and not the view. I think my brain
is getting fried too much lately, making dumb errors.

Thanks again.
回复全部
回复作者
转发
0 个新帖子