UIScrollView - cant get my background to be transparent

897 views
Skip to first unread message

Bob

unread,
Apr 7, 2009, 1:20:23 PM4/7/09
to 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

unread,
Apr 8, 2009, 1:57:39 PM4/8/09
to 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

unread,
Apr 10, 2009, 9:19:46 AM4/10/09
to 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.
Reply all
Reply to author
Forward
0 new messages