美文网首页
绘制六边形的方法

绘制六边形的方法

作者: lion_xion | 来源:发表于2015-10-28 19:56 被阅读92次

    floatviewWidth =45;

    UIBezierPath* path = [UIBezierPathbezierPath];

    path.lineWidth=2;

    [[UIColorwhiteColor]setStroke];

    [pathmoveToPoint:CGPointMake((sin(M_1_PI/180*60)) * (viewWidth /2), (viewWidth /4))];

    [pathaddLineToPoint:CGPointMake((viewWidth /2),0)];

    [pathaddLineToPoint:CGPointMake(viewWidth - ((sin(M_1_PI/180*60)) * (viewWidth /2)), (viewWidth /4))];

    [pathaddLineToPoint:CGPointMake(viewWidth - ((sin(M_1_PI/180*60)) * (viewWidth /2)), (viewWidth /2) + (viewWidth /4))];

    [pathaddLineToPoint:CGPointMake((viewWidth /2), viewWidth)];

    [pathaddLineToPoint:CGPointMake((sin(M_1_PI/180*60)) * (viewWidth /2), (viewWidth /2) + (viewWidth /4))];

    [pathclosePath];

    CAShapeLayer* shapLayer = [CAShapeLayerlayer];

    shapLayer.lineWidth=2;

    shapLayer.strokeColor= [UIColorwhiteColor].CGColor;

    shapLayer.path= path.CGPath;

    self.coverImageView.layer.mask= shapLayer;

    相关文章

      网友评论

          本文标题:绘制六边形的方法

          本文链接:https://www.haomeiwen.com/subject/qclthttx.html