IOS图片设置阴影

#import 
- (void)viewDidLoad  
{  
    [super viewDidLoad];  
    UIImage *img = [UIImage imageNamed:@"Icon.png"];  
    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];  
    imgView.center = self.view.center;  
    [[imgView layer] setShadowOffset:CGSizeMake(5, 5)]; // 阴影的范围  
    [[imgView layer] setShadowRadius:2];                // 阴影扩散的范围控制  
    [[imgView layer] setShadowOpacity:1];               // 阴影透明度  
    [[imgView layer] setShadowColor:[UIColor brownColor].CGColor]; // 阴影的颜色  
    [self.view addSubview:imgView];  
}  

你可能感兴趣的:(IOS开发)