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];
Run Code Online (Sandbox Code Playgroud)
使用此代码时,我收到以下警告:
从不兼容的指针类型传递'setShadowColor:'的参数1
代码编译得很好,图像显示正确,但没有阴影.
我究竟做错了什么?
我想这有点晚了.
正如Dasdom已经写道:
img.layer.shadowColor = [[UIColor blackColor] CGColor];
img.layer.shadowOpacity = 1.0f;
img.layer.shadowRadius = 8.0f;
Run Code Online (Sandbox Code Playgroud)
但是你必须确保imageView没有被剪裁到它的框架:
img.clipsToBounds = NO;
Run Code Online (Sandbox Code Playgroud)
迈克尔
| 归档时间: |
|
| 查看次数: |
3784 次 |
| 最近记录: |