aherlambang
aherlambang

Reputation: 14418

border in UIImageView

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?

Upvotes: 2

Views: 5068

Answers (3)

Prashant Solanki
Prashant Solanki

Reputation: 112

imageView.layer.shadowOpacity=0.6;
imageView.layer.shadowRadius = 0.0;
imageView.layer.shadowColor = [UIColor grayColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(-2.0, 1.0);

Upvotes: 2

justin
justin

Reputation: 5831

This question about adding shadows to UIImageView might help

Upvotes: 2

jaminguy
jaminguy

Reputation: 25940

Take a look at the shadow properties of CALayer.

[imageView.layer setShadowOffset:CGSizeMake(-1.0, -1.0)];
[imageView.layer setShadowOpacity:0.5];

Upvotes: 4

Related Questions