我有 4 张卡片,我可以翻转卡片,我想检查我的图像是否相同,显示 2 张图像,如果不是背面翻转,
你能给我一些教程或示例代码吗?
提前致谢!
编辑:
这是我的图片:
UIImage *img1 = [UIImage imageNamed:@"card_front.png"];
[self addCardAtX:90 y:120 andFrontImage:img1 andTag:1];
[self addCardAtX:230 y:120 andFrontImage:img1 andTag:1];
[self addCardAtX:90 y:340 andFrontImage:img1 andTag:1];
[self addCardAtX:230 y:340 andFrontImage:img1 andTag:1];
- (void)addCardAtX:(CGFloat)x y:(CGFloat)y andFrontImage:(UIImage *) img1 andTag:(int)tag
{
UIImage *img2= [UIImage imageNamed:@"card_back.png"];
CardView *cv = [[CardView alloc] initWithFrontImage:img1 backImage:img2];
CGRect f = cv.frame;
f.origin.x = x-(f.size.width/2.0);
f.origin.y = y-(f.size.height/2.0);
cv.frame = f;
[self.view addSubview:cv];
}