I want to overlay an image over a button. the button has a background image. If i want to overlay a semi transparent image over the button, suppose i overlay a red color image, which is semi transparent. Can any one suggest how to do that? Suggest some documentation.
+2
A:
UIImageView *overlay = [[UIImageView alloc] initWithImage:...];
[overlay setAlpha:0.5];
UIButton *button = [[UIButton alloc] initWithType:UIButtonTypeRoundedRect];
[button setBackgroundImage:...];
[button addSubview:overlay];
[overlay release];
UIButton also has an image
property as well as a backgroundImage
property, although I'm unsure how transparency would work with it.
dc
2010-08-25 06:21:21
+1
A:
Following dc answer, note that changing the button alpha will affect also the overlay transparency, so check that button alpha is 1.0f (default value).
Note also that you should release the overlay variable after adding it as subview to button, otherwise, you'll get a memory leak.
Meir Assayag
2010-08-25 09:32:33
Thanks, forgot about that.
dc
2010-08-25 17:38:17