cs193p – Assignment #1 Task #7

Please note, this blog entry is from a previous course. You might want to check out the current one.

Make the back of the card be an image (UIImage) rather than an Apple logo.

Add an image to your project (e.g. cardback.png), create an UIImage from it, use it when the back of the card is shown, and remove it when it is face up:

- (void)updateUI
{
    UIImage *cardBackImage = [UIImage imageNamed:@"cardback.png"];
    
    for (UIButton *cardButton in self.cardButtons) {
        ...
        if (!card.isFaceUp) {
            [cardButton setImage:cardBackImage 
                        forState:UIControlStateNormal];            
        } else {
            [cardButton setImage:nil forState:UIControlStateNormal];
        }
    }
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published.