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;

 

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM