Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
938
41
Tokyo, Japan
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?
 

Attachments

  • title.png
    title.png
    17.4 KB · Views: 289
  • SnapShot 2011-01-09 at 1.28.35.jpg
    SnapShot 2011-01-09 at 1.28.35.jpg
    69.5 KB · Views: 89
What code? You haven't posted any
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];
 
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.
 
Great! I got it, thank you very much!

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.