关于iOS的划线绘图

2017-03-18  本文已影响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();

上一篇 下一篇

猜你喜欢

热点阅读