【问题标题】:how to draw a full line tlll the end screen如何画一条完整的线直到结束屏幕
【发布时间】:2014-02-12 05:24:47
【问题描述】:

我对我的数学感到震惊....

我在视图上绘制 8 条红线,完全延伸到边缘,但它没有。

我错过了什么吗?附上截图以更好地解释它

 NSDictionary *d=@{@(0): @0,
                      @(1): @45,
                      @(2): @90,
                      @(3): @135,
                      @(4): @180,
                      @(5): @-45,
                      @(6): @-90,
                      @(7): @-135,
                      @(8): @-180};

    for (int i=0; i<8; i++)
    {
        CGContextSetLineWidth       (ctx, 1.5);
        CGContextSetRGBStrokeColor  (ctx, 255.0, 0.0, 0.0, 1.0);
        CGContextMoveToPoint        (ctx, 160, 240);
        CGFloat degreeFloat  = [d[@(i)] floatValue]  ;
        CGFloat deltaX = radius * cosf(RADIANS([d[@(i)] floatValue] ));
        CGFloat deltaY = radius * sinf(RADIANS([d[@(i)] floatValue] ));
        CGFloat endX = 160 + deltaX;
        CGFloat endy = 240 + deltaY;
        CGContextAddLineToPoint(ctx, endX, endy);
        CGContextStrokePath(ctx);
        //CGContextRef ctx = UIGraphicsGetCurrentContext();
    }

【问题讨论】:

    标签: ios objective-c core-graphics cgcontext


    【解决方案1】:

    抱歉,我不确定您的问题是什么,但如果您希望这些行更长,为什么不增加radius?

    【讨论】:

    • 嗨,你是对的!简单的错误。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-09
    • 1970-01-01
    • 2019-08-22
    • 1970-01-01
    相关资源
    最近更新 更多