円形のビューの後ろに影を追加しようとしていますが、ビューの境界にある影だけになりました。この影は、ビューの周囲全体(上部のみ)には表示されません。これが私のコードです:
-(void)drawRect:(CGRect)dirtyRect{
CGContextRef ctx=UIGraphicsGetCurrentContext();
CGRect bounds=[self bounds];
// Figure out the centre of the bounds rectangle
CGPoint centre;
centre.x=bounds.origin.x+0.5*bounds.size.width;
centre.y=bounds.origin.y+0.5*bounds.size.height;
// Clip context
CGPathRef path = CGPathCreateWithEllipseInRect(bounds, NULL);
CGContextAddPath(ctx, path);
CGContextClip(ctx);
// Add black outline
path = CGPathCreateWithEllipseInRect(bounds, NULL);
CGContextAddPath(ctx, path);
[[UIColor blackColor] setStroke];
CGContextSetLineWidth(ctx, 3.0);
// Specify shadow
CGSize offset=CGSizeMake(1,4);
CGColorRef colour=[[UIColor darkGrayColor] CGColor];
CGContextSetShadowWithColor(ctx, offset, 2, colour);
// Draw image
UIImage *littleImage=[UIImage imageNamed:@"image.png"];
[littleImage drawInRect:bounds];
CGContextStrokePath(ctx);
}
読んでくれてありがとう。