【问题标题】:Draw curved arrow between two points using Quartz Core in iPhone在 iPhone 中使用 Quartz Core 在两点之间绘制曲线箭头
【发布时间】:2011-04-28 12:27:58
【问题描述】:

我想在 iPhone 应用程序中使用 Quartz Core 框架在两点之间绘制一条带箭头的曲线。如何做到这一点或有哪些类可以做到这一点?

【问题讨论】:

标签: iphone line quartz-graphics


【解决方案1】:

你可以随意改变坐标

 - (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);

}

【讨论】:

  • 请至少链接到您复制和粘贴答案的来源。在这种情况下,这就是An iPhone Graphics Drawing Tutorial using Quartz 2D,这对海报非常有用。
  • 我提供的代码取自您提供的链接
  • 我知道,但你应该自己这么说!首先,简单地复制和粘贴而不透露来源是不礼貌的(有时甚至是非法的,但在这种情况下不是)。其次,该链接提供了更多有价值的信息。
  • 奈米:这没有意义。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-19
  • 2017-02-18
  • 2022-08-22
  • 1970-01-01
相关资源
最近更新 更多