Drawing a polygon with one color for stroke, and a different one for fill?

前端 未结 3 468
鱼传尺愫
鱼传尺愫 2020-12-09 13:28

I\'m having trouble with drawing some lines that are stroked with a color and then filling their insides (they make a polygon) with another one.

UIColor *hou         


        
3条回答
  •  醉酒成梦
    2020-12-09 13:49

    Using UIBezierPath you could do this:

    UIBezierPath *path = [[UIBezierPath alloc] init];
    [path moveToPoint:CGPointMake(20, viewHeight-19.5)];
    [path addLineToPoint:CGPointMake(200, viewHeight-19.5)];
    [path addLineToPoint:CGPointMake(300, viewHeight-119.5)];
    [path addLineToPoint:CGPointMake(120, viewHeight-119.5)];
    [path addLineToPoint:CGPointMake(20, viewHeight-19.5)];
    
    [[UIColor colorWithRed:(248/255.0) green:(222/255.0) blue:(173/255.0) alpha:1.0] setFill];
    [path fill];
    [[UIColor colorWithRed:(170/255.0) green:(138/255.0) blue:(99/255.0) alpha:1.0] setStroke];
    [path stroke];
    

提交回复
热议问题