相关疑难解决方法(0)

Core Graphics - 如何在不画线的情况下绘制阴影?

看看这段代码:

- (void)drawRect:(CGRect)rect
{
  [super drawRect:rect];

  CGContextRef context = UIGraphicsGetCurrentContext();

  CGSize  myShadowOffset = CGSizeMake (-10,  15);

  CGContextSaveGState(context);

  CGContextSetShadow (context, myShadowOffset, 5);

  CGContextSetLineWidth(context, 4.0);
  CGContextSetStrokeColorWithColor(context,
                                 [UIColor blueColor].CGColor);
  CGRect rectangle = CGRectMake(60,170,200,200);
  CGContextAddEllipseInRect(context, rectangle);
  CGContextStrokePath(context);
  CGContextRestoreGState(context);
}
Run Code Online (Sandbox Code Playgroud)

它所做的就是为这个圆圈绘制一个圆圈和一个阴影。但是我想不通如何只画阴影而不画圆圈?我怎么做?SO上类似问题的答案对我没有帮助

core-graphics objective-c ios

3
推荐指数
2
解决办法
3149
查看次数

标签 统计

core-graphics ×1

ios ×1

objective-c ×1