Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add border to a image in iphone

Tags:

xcode

iphone

I have an image in a custom cell. Is there any api to add a gray border to an image?

Thanks in advance!

like image 736
Iya Avatar asked Dec 17 '22 05:12

Iya


1 Answers

If you are on iPhone OS 3.0, you can use the borderWidth and borderColor properties of your image view's CALayer to add a border over the image, as follows:

imageView.layer.borderWidth = 4.0f;
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = {0.5, 0.5, 0.5, 1.0}; 
CGColorRef grey = CGColorCreate(space, values); 
imageView.layer.borderColor = grey;
CGColorRelease(grey);
CGColorSpaceRelease(space);

This creates a 4-pixel-wide border with a fully opaque color having RGB values midway between white and black.

like image 101
Brad Larson Avatar answered Jan 01 '23 11:01

Brad Larson