Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何为UIImageView应用拐角半径和阴影偏移_Ios_Uiimageview_Ios7.1_Quartz Core - Fatal编程技术网

Ios 如何为UIImageView应用拐角半径和阴影偏移

Ios 如何为UIImageView应用拐角半径和阴影偏移,ios,uiimageview,ios7.1,quartz-core,Ios,Uiimageview,Ios7.1,Quartz Core,我正在开发一个电子商务应用程序。我需要用阴影偏移量在圆角处显示产品列表图像。两者都不在一起工作&我尝试了很多解决方案,但没有人能解决我的问题。任何帮助都将不胜感激 更新代码: UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20,260,45,45)]; imageView.backgroundColor = [UIColor grayColor]; UIImage *image = [UIImage

我正在开发一个电子商务应用程序。我需要用
阴影偏移量
在圆角处显示产品列表图像。两者都不在一起工作&我尝试了很多解决方案,但没有人能解决我的问题。任何帮助都将不胜感激

更新代码:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20,260,45,45)];
imageView.backgroundColor = [UIColor grayColor];
UIImage *image = [UIImage imageNamed:@"sample.png"];
imageView.image = image;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds
                                               byRoundingCorners:UIRectCornerAllCorners
                                                     cornerRadii:CGSizeMake(22.5, 22.5)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = imageView.bounds;
maskLayer.path = maskPath.CGPath;
[imageView.layer setMask:maskLayer];

[imageView.layer setShadowOffset:CGSizeMake(0, 3)];
[imageView.layer setShadowOpacity:0.4];
[imageView.layer setShadowRadius:3.0f];
[imageView.layer setCornerRadius:22.0f];
imageView.layer.shadowColor=[UIColor redColor].CGColor;
imageView.layer.borderColor=[UIColor blackColor].CGColor;
imageView.layer.borderWidth=1.0;
[self.view addSubview:imageView];
谢谢和问候
Sam.P

我尝试过该解决方案,但不适用于我