使用UIbezierPath画一个阴影图片

有一个阴影图像,需要画在UITableView 区域的外围。图片:

CSDN移动问答

我能获取代表矩形的UIBezierPath,但是不知道应该怎么沿着举行的周围进行重复画图。目前我只能图片充填矩形。

UIImage *patternImg = [UIImage imageNamed:@"cellShadow"];
UIColor *fill = [UIColor colorWithPatternImage:patternImg];
[fill setFill];
CGRect aSectRect = [self rectForSection:0];
UIBezierPath *aSectPath = [self createRoundedPath:aSectRect];
[aSectPath fill];

可以操作view的layer的shadow****系列属性 来控制view显示的阴影效果

  //阴影颜色
  view.layer.shadowColor = [[UIColor colorWithRed:1.0 green:0 blue:0 alpha:1] CGColor];
  //阴影offset
  view.layer.shadowOffset = CGSizeMake(0, 3);
  //阴影path
  view.layer.shadowPath = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;;
  //不透明度
  view.layer.shadowOpacity = 0.6;
  //阴影圆角半径
  view.layer.shadowRadius = 3;