美文网首页
关于iOS的划线绘图

关于iOS的划线绘图

作者: 加基特 | 来源:发表于2017-03-18 15:55 被阅读56次

//可以通过这种方法绘制复杂图形

UIImageView* lineImage = [[UIImageViewalloc]initWithFrame:CGRectMake(kScaleWidth(94),kScaleHeight(191),kScaleWidth(204),kScaleHeight(2))];

[self.viewaddSubview:lineImage];

UIGraphicsBeginImageContext(lineImage.frame.size);

[lineImage.imagedrawInRect:CGRectMake(0,0, lineImage.frame.size.width, lineImage.frame.size.height)];

CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound);

CGContextSetLineWidth(UIGraphicsGetCurrentContext(),10.0);

CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(),YES);

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),1.0,1.0,1.0,1.0);

CGContextBeginPath(UIGraphicsGetCurrentContext());

CGContextMoveToPoint(UIGraphicsGetCurrentContext(),0,0);

CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),kScaleWidth(204),kScaleHeight(0));

CGContextStrokePath(UIGraphicsGetCurrentContext());

lineImage.image=UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

相关文章

网友评论

      本文标题:关于iOS的划线绘图

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