0

I have created one UIImageView Here's code

capView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kARROW_CAP_NAME]];
capView.frame = CGRectMake(0, 0, kARROW_H, kARROW_H);
[self addSubview:capView];

Now I have two points which I need to move around View, So, they are Updating..

PointA, PointB

I got the angle between them:

CGFloat angleBetweenPoints(CGPoint first, CGPoint second) 
{
    CGFloat height = second.y - first.y;
    CGFloat width = first.x - second.x;
    CGFloat rads = atan(height/width);
    return RADIANS_TO_DEGREES(rads);
}

When I apply this angle to my UIImageView, it continuously change,

My used code here:

capView.transform = CGAffineTransformMakeRotation(arrowAngle);

or

capView.transform = CGAffineTransformRotate(self.transform, arrowAngle);

Arrow Angle is the value of above function which i write above..

Please take a look and help me.

rptwsthi
  • 10,094
  • 10
  • 68
  • 109
Solid Soft
  • 1,872
  • 2
  • 25
  • 55

1 Answers1

0

Got the answer, So simple..

But still no one give me answer..

capView.transform = CGAffineTransformMakeRotation(RADIANS(M_PI_2 - arrowAngle))

And RADINAS is macro define here,

#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

Thanks to all who be a part of it..

Solid Soft
  • 1,872
  • 2
  • 25
  • 55