Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // you must set both of these
- CGPoint centerOfCircle;
- float radius;
- int count = 0;
- float angleStep = 2.0f * M_PI / [arrayOfViews count];
- for (UIView *view in arrayOfViews) {
- float xPos = cosf(angleStep * count) * radius;
- float yPos = sinf(angleStep * count) * radius;
- view.center = CGPointMake(centerOfCircle.x + xPos, centerOfCircle.y +yPos);
- count++;
- }
- // These calculate the x and y offset from the center by using the angle in radians
- #define LengthDir_X(__Length__,__Direction__) (cos(__Direction__)*__Length__)
- #define LengthDir_Y(__Length__,__Direction__) (sin(__Direction__)*__Length__)
- // I use this to convert degrees to radians and back if I have to
- #define DegToRad(__ANGLE__) (((__ANGLE__) * 2.0 * M_PI) / 360.0)
- #define RadToDeg(__ANGLE__) (((__ANGLE__) * 360) / (2.0 * M_PI))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement