1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

How to avoid black color for image as background

Discussion in 'iPhone/iPad Programming' started by mikezang, Jan 8, 2011.

  1. macrumors 6502a

    #1
    I have a image, I am using code as below to set it as UIView's background color, but I found there are black color, how can I avoid black with Transparency?
     

    Attached Files:

  2. Moderator

    robbieduncan

    Staff Member

    #2
    What code? You haven't posted any
     
  3. macrumors 6502a

    #3
    Sorry, I forgot to paste.

    Code:
    self.titleView = [[UIView alloc] initWithFrame:CGRectMake(30, 10, 256, 50)];
    self.titleView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"title.png"]];
    [self.titleView addSubview:title];
    [title release];
    
     
  4. Moderator

    robbieduncan

    Staff Member

    #4
    As you have not set the opaque property of the view to NO the drawing system assumes (as it should) that the view has no areas with alpha < 1.0. I'd try setting that property.
     
  5. macrumors 6502a

    #5
    Great! I got it, thank you very much!
     
  6. macrumors regular

    #6
    optionally, since this doesnt seem to be a patterned image.(forgive me if it is)

    You can use a UIImageView. Set the image property to your titleimage.png and set the backgroundcolor of the UIImageView to clearColor.
     

Share This Page