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我尝试过该解决方案,但不适用于我