2013-11-03 73 views

回答

0

,你必須有一個透明背景設置圖像,然後你添加陰影像:

imageView.layer.shadowColor = [UIColor blackColor].CGColor; 
    imageView.layer.shadowOpacity = 0.1; 
    imageView.layer.shadowRadius = 5; 
    imageView.layer.shadowOffset = CGSizeMake(5, 5); 
    [imageView setClipsToBounds:NO]; 

記住你必須輸入QuarzCore庫

+3

這僅僅增加了一個陰影圍繞着兩面圖像視圖框架。這個問題似乎是關於將一​​個節目應用於不規則形狀的圖像。 – rmaddy

+0

你能展示你想要什麼圖片嗎? –

+0

rmaddy,你說得對,我需要你說的。 – arturdev

0

嘛!你可以試試這個。

// Use a White background to make the shadow prominent. 
self.view.backgroundColor = [UIColor whiteColor]; 

// The image we're going to mask and shadow 
UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.jpeg"]]; 
image.center = self.view.center; 

// make new layer to contain shadow and masked image 
CALayer* containerLayer = [CALayer layer]; 
containerLayer.shadowColor = [UIColor blackColor].CGColor; 
containerLayer.shadowRadius = 10.f; 
containerLayer.shadowOffset = CGSizeMake(0.f, 5.f); 
containerLayer.shadowOpacity = 1.f; 

// use the image's layer to mask the image into a circle 
image.layer.cornerRadius = roundf(image.frame.size.width/2.0); 
image.layer.masksToBounds = YES; 

// add masked image layer into container layer so that it's shadowed 
[containerLayer addSublayer:image.layer]; 

// add container including masked image and shadow into view 
[self.view.layer addSublayer:containerLayer]; 
3

爲了給陰影效果的UIImageView嘗試以下代碼..

1)#import <QuartzCore/QuartzCore.h> in .h file

2)To give a shadow effect to Cell's UIImageView

mediaImage.layer.shadowColor = [UIColor blackColor].CGColor; 
mediaImage.layer.shadowRadius = 10.f; 
mediaImage.layer.shadowOffset = CGSizeMake(0.f, 5.f); 
mediaImage.layer.shadowOpacity = 1.f; 
mediaImage.clipsToBounds = NO;