我有一个应用程序,您有 3 个按钮,如果您按下一个按钮,三个按钮的按钮图像会发生变化,但按钮 2 和按钮 3 的图片可能与按钮 1 的图片不同,而按钮 3 的图片可能与按钮 2 的图片不同
我已经尝试过了,但它没有用
NSInteger imageIndex1 = arc4random_uniform(images.count);
NSInteger imageIndex2 = arc4random_uniform(images.count);
NSInteger imageIndex3 = arc4random_uniform(images.count);
if (imageIndex1 == imageIndex2 ) {
imageIndex2 = arc4random_uniform(images.count);
}
else if (imageIndex1 == imageIndex3 ) {
imageIndex3 = arc4random_uniform(images.count);
}
else if (imageIndex2 == imageIndex3 ) {
imageIndex3 = arc4random_uniform(images.count);
}
else
[self.picture1 setImage:images[imageIndex1] forState:UIControlStateNormal];
[self.picture2 setImage:images[imageIndex2] forState:UIControlStateNormal];
[self.picture3 setImage:images[imageIndex3] forState:UIControlStateNormal];
imageIndex1 = imageIndex2;
imageIndex1 = imageIndex3;
imageIndex2 = imageIndex3;