Question

i got struck abit on my math....

i am drawing 8 red lines on a view fully extend till the edge however it didn't.

am i missing something ? attached screenshots to explain it better

enter image description here

 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();
    }
Was it helpful?

Solution

Sorry I'm not really sure what your problem is but if you want those lines to be longer, why don't you just increase radius?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top