How do I create开发者_如何学运维 a white border and black shadow for my UIImageView?
Just import
#import <QuartzCore/QuartzCore.h>
and make sure that you have the QuartzCore framework added to your project.
Then to add border
[imageView.layer setBorderColor: [[UIColor whiteColor] CGColor]];
[imageView.layer setBorderWidth: 2.0];
To create shadow, see this SO question, which will get you going..
this is the way I add a border and shadow to an UIImage in a UIMageView
someImageView.image = someUIImage;
someImageView.frame = CGRectMake(45, 25, 50, 50);
[someImageView.layer setBorderColor: [[UIColor whiteColor] CGColor]];
[someImageView.layer setBorderWidth: 2.0];
[someImageView.layer setShadowOffset:CGSizeMake(-3.0, 3.0)];
[someImageView.layer setShadowRadius:3.0];
[someImageView.layer setShadowOpacity:1.0];
remember:
#import <QuartzCore/QuartzCore.h>
You can just add it as another UIImageView behind the one showing your image.
精彩评论