- (void)test5{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10, 10)];
[path addLineToPoint:CGPointMake(200, 200)];
[path addLineToPoint:CGPointMake(200, 10)];
[path stroke];
}
/**
* //c+oc第四种方式
*/
- (void)test4{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 10, 10);
CGPathAddLineToPoint(path, NULL, 20 , 20);
UIBezierPath *path1 = [UIBezierPath bezierPathWithCGPath:path];
[path1 addLineToPoint:CGPointMake(300, 20)];
CGContextAddPath(ref, path1.CGPath);
CGContextStrokePath(ref);
}
/**
* //C和OC 嗲三种方式
*/
- (void)test3{
CGContextRef ref = UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10, 10)];
[path addLineToPoint:CGPointMake(100, 100)];
CGContextAddPath(ref, path.CGPath);
CGContextStrokePath(ref);
}
/**
* C的第二种方式
*/
- (void)test2{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 10, 10);
CGPathAddLineToPoint(path, NULL, 100, 100);
CGPathAddLineToPoint(path, NULL, 100, 0);
CGContextAddPath(ref, path);
CGContextStrokePath(ref);
}
- (void)test1{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(ref, 10, 10);
CGContextAddLineToPoint(ref, 200, 200);
CGContextAddLineToPoint(ref, 200, 100);
CGContextMoveToPoint(ref, 20, 10);
CGContextAddLineToPoint(ref, 200, 90);
CGContextMoveToPoint(ref, 20, 20);
CGContextAddLineToPoint(ref, 100, 0);
CGContextStrokePath(ref);
}