Reputation: 940
NSString *imgPath = [[jsonObjects objectAtIndex:indexPath.row] valueForKey:@"image"];
NSData *imgData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imgPath]];
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(20, 7, 44, 44)];
img.image = [UIImage imageWithData:imgData];
img.layer.shadowColor = [UIColor blackColor];
img.layer.shadowOffset = CGSizeMake(1, 2);
[cell addSubview:img];
[imgPath release];
[imgData release];
[img release];
When using this code, I get the following warning:
Passing argument 1 of 'setShadowColor:' from incompatible pointer type
The code compiles just fine and the image is shown correctly, but without a shadow.
What am I doing wrong?
Upvotes: 2
Views: 3872
Reputation: 22
I think you should try this:
sender.layer.shadowColor=[[UIColor yellowColor]CGColor];
sender.layer.shadowRadius=10;
sender.layer.shadowOffset=CGSizeMake(1, 1);
sender.layer.shadowOpacity=1;
here sender is UIButton
type.
Upvotes: 0
Reputation: 2278
I suppose it's a bit late.
It is as Dasdom already wrote :
img.layer.shadowColor = [[UIColor blackColor] CGColor];
img.layer.shadowOpacity = 1.0f;
img.layer.shadowRadius = 8.0f;
But you have to ensure that the imageView is not clipped to its frame:
img.clipsToBounds = NO;
Michael
Upvotes: 6
Reputation: 14063
Change the line
img.layer.shadowColor = [UIColor blackColor];
to
img.layer.shadowColor = [[UIColor blackColor] CGColor];
and add
img.layer.shadowOpacity = 1.0f;
img.layer.shadowRadius = 8.0f;
Upvotes: 0