CAShapeLayer* shadowLayer = [CAShapeLayerlayer];

[shadowLayersetFrame:_imageView.bounds];

// Standard shadow stuff

[shadowLayersetShadowColor:[[UIColorcolorWithWhite:0alpha:0.8]CGColor]];

[shadowLayersetShadowOffset:CGSizeMake(0.0f,0.0f)];

[shadowLayersetShadowOpacity:1.0f];

// Causes the inner region in this example to NOT be filled.

[shadowLayersetFillRule:kCAFillRuleEvenOdd];

// Create the larger rectangle path.

CGMutablePathRefpath =CGPathCreateMutable();

CGPathAddRect(path,NULL,CGRectInset(_imageView.bounds, -42, -42));

// Add the inner path so it's subtracted from the outer path.

// someInnerPath could be a simple bounds rect, or maybe

// a rounded one for some extra fanciness.

CGPathRefsomeInnerPath = [UIBezierPathbezierPathWithRoundedRect:_imageView.boundscornerRadius:10.0f].CGPath;

CGPathAddPath(path,NULL, someInnerPath);

CGPathCloseSubpath(path);

[shadowLayersetPath:path];

CGPathRelease(path);

[[_imageViewlayer]addSublayer:shadowLayer];

CAShapeLayer* maskLayer = [CAShapeLayerlayer];

[maskLayersetPath:someInnerPath];

[shadowLayersetMask:maskLayer];

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐