iOS开发 画六边形(多边形)

- (void)drawRect:(CGRect)rect {

  UIBezierPath * path = [UIBezierPath bezierPath];

  [path moveToPoint:CGPointMake(fView_Width(self)/2., 6*DX_Proportion)];

  [path addLineToPoint:CGPointMake(fView_Width(self) - 6*DX_Proportion, 30/2.*DX_Proportion + 6*DX_Proportion)];

  [path addLineToPoint:CGPointMake(fView_Width(self) - 6*DX_Proportion, 90/2.*DX_Proportion + 6*DX_Proportion)];

  [path addLineToPoint:CGPointMake(fView_Width(self)/2., fView_Height(self) - 6*DX_Proportion)];

  [path addLineToPoint:CGPointMake(6*DX_Proportion, 90/2.*DX_Proportion + 6*DX_Proportion)];

  [path addLineToPoint:CGPointMake(6*DX_Proportion, 30/2.*DX_Proportion + 6*DX_Proportion)];

  [path closePath];

  path.lineWidth = 3*DX_Proportion;

  [self.linColor set];

  [path stroke];    

  

  CAShapeLayer * shapLayer = [CAShapeLayer layer];

  

  shapLayer.path = path.CGPath;

  self.imageView.layer.mask = shapLayer;

 

}

 

posted @ 2016-12-23 11:12  D-Ben  阅读(2178)  评论(0编辑  收藏  举报