Transparent background for a UIWebView?

Discussion in 'Mac Programming' started by attodorov, May 6, 2008.

  1. attodorov macrumors newbie

    Apr 17, 2008
    Hi guys,

    Is there any way to make the background of a UIWebView transparent (i.e. clearColor)? I have tried everything I can think of - setting the backgroundColor to clearColor, setting transparency in the CSS itself, when I load HTML from a String, it just doesn't work - the background always stays white.

    Actually if I set some other color than white (such as blue) in the HTML/CSS, the view background is correctly set to that color.

    Is this some kind of bug? Because in the API docs, there is nothing mentioned that the background cannot be transparent.

    What I really want to do is display rich text on a View. This is not possible with UITextView because it doesn't allow any attributed strings to be used - the text is only of one predefined font/color... So the only way is supposed to be UIWebView.

    Thanks very much for your feedback.
  2. MongoTheGeek macrumors 68040


    Sep 13, 2003
    Its not so much where you are as when you are.
    The clear color may be working. What color is the the thing that the webview is on? Probably the NSWindow?

    This one bit me before.
  3. tominated macrumors 68000


    Jul 7, 2006
    Queensland, Australia
    i know it is possible because the debug menu in safari has an option for it, but i just don't know how. sorry
  4. Sayer macrumors 6502a


    Jan 4, 2002
    Austin, TX
    On Mac OS X you can add a category to the WebView class to add the setDrawsBackground method to a web view and make the background transparent. I did this in a WebKit-based app a few months ago.

    	@interface WebView (PRIVATE) 
    I wonder if something similar would work on Cocoa Touch?
  5. macrumor.99 macrumors newbie

    May 7, 2008
    transparency in css

    Is there any way to set the transparency in the css for mac Users. For example when I go to and log in > go to clubs then select a nightclub and try to add it by clicking on the add button its seems to work there. But when I try to reproduce on my site it only works in ie and firefox.

    Im sorry I can't produce an example of a site that dosnt require you be authenicated but this is the only site that I have seen it working on.
  6. attodorov thread starter macrumors newbie

    Apr 17, 2008
    Hi guys,

    Thanks for your replies - but please note that I have the iPhone SDK in mind, not pure Cocoa.

    About CSS - there are several ways to set transparency using CSS but it doesn't seem to work in the UIWebView context.

  7. Sbrocket macrumors 65816


    Jun 3, 2007
    Has there been any updates on this? I'm wondering the same thing at the moment, since I need a transparent UIWebView.
  8. tigermain macrumors newbie

    Apr 2, 2009

Share This Page