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