2

I am trying to have an UIImageView bordered like the following:

enter image description here

I have tried using:

[imageView.layer setBorderColor: [[UIColor whiteColor] CGColor]];
[imageView.layer setBorderWidth: 2.0];

but then you can't see that gray border on the outside. It has that gray shadow effect on the outside. How do I do this?

aherlambang
  • 14,144
  • 49
  • 147
  • 248

3 Answers3

4

Take a look at the shadow properties of CALayer.

[imageView.layer setShadowOffset:CGSizeMake(-1.0, -1.0)];
[imageView.layer setShadowOpacity:0.5];
jaminguy
  • 25,700
  • 2
  • 21
  • 21
2
imageView.layer.shadowOpacity=0.6;
imageView.layer.shadowRadius = 0.0;
imageView.layer.shadowColor = [UIColor grayColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(-2.0, 1.0);
2

This question about adding shadows to UIImageView might help

Community
  • 1
  • 1
justin
  • 5,821
  • 3
  • 28
  • 32