Transparent background for a UIWebView?

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

  1. attodorov macrumors newbie

    Joined:
    Apr 17, 2008
    #1
    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

    MongoTheGeek

    Joined:
    Sep 13, 2003
    Location:
    Its not so much where you are as when you are.
    #2
    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

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #3
    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

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #4
    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.

    Code:
    	@interface WebView (PRIVATE) 
     	(void)setDrawsBackground:(BOOL)flag; 
    	(BOOL)drawsBackground; 
    	@end 
    I wonder if something similar would work on Cocoa Touch?
     
  5. macrumor.99 macrumors newbie

    Joined:
    May 7, 2008
    #5
    transparency in css

    Is there any way to set the transparency in the css for mac Users. For example when I go to www.Clubpath.com 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

    Joined:
    Apr 17, 2008
    #6
    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.

    Thanks,
    Angel
     
  7. Sbrocket macrumors 65816

    Sbrocket

    Joined:
    Jun 3, 2007
    Location:
    /dev/null
    #7
    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

    Joined:
    Apr 2, 2009

Share This Page