Created
November 21, 2012 15:31
-
-
Save robinhayward/4125463 to your computer and use it in GitHub Desktop.
Evenly spacing items from their center
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)midPointsForContainerWidth:(CGFloat)containerWidth itemWidth:(CGFloat)itemWidth itemCount:(NSInteger)itemCount | |
{ | |
CGFloat itemSpace = (containerWidth - (itemCount * itemWidth)) / (itemCount + 1); | |
for (int i = 0; i < itemCount; i++) { | |
CGFloat point = itemSpace + ((itemWidth / 2)); | |
if (i > 0) { | |
point += (itemWidth * i); | |
point += (itemSpace * i); | |
} | |
DLog(@"Point %f",point); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment