【发布时间】:2019-02-07 02:53:27
【问题描述】:
单击按钮时,我试图在两个不同的图像之间切换。以下是我到目前为止编写的代码。但是,这只会显示一张图片,不会在它们之间切换。
-(IBAction)show {
BOOL img = true;
if (img = true) {
UIImage *img1 = [UIImage imageNamed:@"UnCheck.png"];
[imageview setImage:img1];
}
else {
UIImage *img = [UIImage imageNamed:@"Check.png"];
[imageview setImage:img];
}
}
【问题讨论】:
-
Setting an image for a UIButton in code 的可能重复项只需将状态更改为您需要的状态即可。
-
-
@kerberos 我遇到的问题是,如果 if 语句设置为“false”,代码总是运行 else
-
问题是什么?
标签: ios objective-c arrays