Created
July 26, 2012 02:03
-
-
Save johncalvinyoung/3179831 to your computer and use it in GitHub Desktop.
Auto-positioning hand draw code
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
CGFloat xOffset = 240 - (((player.hand.count*20)+52)/2); | |
__block CGPoint location = CGPointMake ((CGFloat) xOffset, (CGFloat) 0); | |
[player.hand enumerateObjectsUsingBlock:^(RMSPlayingCard *obj, NSUInteger idx, BOOL *stop) { | |
NSString *rank = obj.rank; | |
NSString *suit = obj.suit; | |
UIImage *cardImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@.png", [[suit substringToIndex:1] lowercaseString], [[rank substringToIndex:1] lowercaseString]]]; | |
UIImageView *cardView = [[UIImageView alloc] initWithFrame:CGRectMake(location.x, location.y, cardImage.size.width, cardImage.size.height)]; | |
[cardView setImage:cardImage]; | |
[self.handView addSubview: cardView]; | |
location.x = location.x+20; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment