我有一个用于玩纸牌游戏的 updateUI 方法,我在卡片背面添加了一张图片,但图片到处都是,我找不到问题..
这是我的方法:我如何调整它以匹配卡片大小?
- (void)updateUI {
for (UIButton *cardButton in self.cardButtons) {
Card *card = [self.game cardAtIndex:[self.cardButtons indexOfObject:cardButton]];
[cardButton setTitle:card.contents forState:UIControlStateSelected];
[cardButton setTitle:card.contents
forState:UIControlStateSelected|UIControlStateDisabled];
cardButton.selected = card.isFaceUp;
cardButton.enabled = !card.isUnplayable;
cardButton.alpha = card.isUnplayable ? 0.3 : 1.0;
cardButton.imageEdgeInsets = UIEdgeInsetsMake(2, 2, 2, 2);
UIImage *cardBackImage = (cardButton.selected) ? nil : [UIImage imageNamed:@"benCardImag.png"];
[cardButton setImage:cardBackImage forState:UIControlStateNormal];
}
self.scoreCounter.text = [NSString stringWithFormat:@"Score: %d", self.game.score];
if (self.game.notification) {
self.notificationLabel.text = self.game.notification;
}
}