Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding black overlay with 0.3 opacity over UIImageView

Tags:

I have a UIImageView and I wanted to add a black overlay on top of it. What is the best way of doing this without having to override drawRect? I was thinking of adding a CALayer on top of it. But unsure how to get a black CALayer with a .3 alpha.

like image 446
xonegirlz Avatar asked Jun 27 '12 00:06

xonegirlz


1 Answers

Something like this?

UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, myImageView.frame.size.width, myImageView.frame.size.height / 2)];
[overlay setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3]];
[myImageView addSubview:overlay];
like image 134
Mick MacCallum Avatar answered Oct 19 '22 00:10

Mick MacCallum