简体   繁体   English

在 iPhone 中使用 Quartz Core 在两点之间绘制曲线箭头

[英]Draw curved arrow between two points using Quartz Core in iPhone

I want to draw a curved line with arrow between two points using the Quartz Core framework in an iPhone Application.我想在 iPhone 应用程序中使用 Quartz Core 框架在两点之间绘制一条带箭头的曲线。 How to do that or any what classes are available to do that?如何做到这一点或有哪些课程可以做到这一点?

You can change the co-ordinates as you want您可以根据需要更改坐标

 - (void)drawRect:(CGRect)rect {

    //DRAW CURVE
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context, 2.0);

    CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

    CGContextMoveToPoint(context, 100, 100);
    CGContextAddArcToPoint(context, 100,200, 300,200, 100);
    CGContextStrokePath(context);

    //DRAW LINE
    CGContextSetLineWidth(context, 2.0);

    CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();

    CGFloat components[] = {0.0, 0.0, 1.0, 1.0};

    CGColorRef color = CGColorCreate(colorspace, components);

    CGContextSetStrokeColorWithColor(context, color);

    CGContextMoveToPoint(context, 0, 0);
    CGContextAddLineToPoint(context, 300, 400);

    CGContextStrokePath(context);
    CGColorSpaceRelease(colorspace);
    CGColorRelease(color);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM