Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // you must set both of these
  2. CGPoint centerOfCircle;
  3. float radius;
  4.  
  5. int count = 0;
  6. float angleStep = 2.0f * M_PI / [arrayOfViews count];
  7.  
  8. for (UIView *view in arrayOfViews) {
  9. float xPos = cosf(angleStep * count) * radius;
  10. float yPos = sinf(angleStep * count) * radius;
  11. view.center = CGPointMake(centerOfCircle.x + xPos, centerOfCircle.y +yPos);
  12. count++;
  13. }
  14.  
  15. // These calculate the x and y offset from the center by using the angle in radians
  16. #define LengthDir_X(__Length__,__Direction__) (cos(__Direction__)*__Length__)
  17. #define LengthDir_Y(__Length__,__Direction__) (sin(__Direction__)*__Length__)
  18.  
  19. // I use this to convert degrees to radians and back if I have to
  20. #define DegToRad(__ANGLE__) (((__ANGLE__) * 2.0 * M_PI) / 360.0)
  21. #define RadToDeg(__ANGLE__) (((__ANGLE__) * 360) / (2.0 * M_PI))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement