我希望在按下UIButton时将默认UIImage
更改为突出显示。因此,当执行以下代码时,我想将另一个的UIImage
更改为突出显示。
- (IBAction)buttonOperationPressed:(id)sender {
if (currentOperation == 0) result = currentNumber;
else {
switch (currentOperation) {
case 1:
result = result + currentNumber;
break;
case 2:
result = result - currentNumber;
break;
case 3:
result = result * currentNumber;
break;
case 4:
result = result / currentNumber;
break;
case 5:
currentOperation = 0;
break;
}
}
currentNumber = 0;
calculatorScreen.text = [NSString stringWithFormat:@"%g", result];
if ([sender tag] ==0) result=0;
currentOperation = [sender tag];
userInTheMiddleOfEnteringDecimal = NO;
}
答案 0 :(得分:0)
UIImage没有突出显示的状态(请查看文档:{{3}})
答案 1 :(得分:0)
我假设您有想要高亮显示的imageView的引用
- (IBAction)buttonOperationPressed:(id)sender{
UIImageView *imageView = [UIImageView alloc] init];
imageView.frame = CGRectMake(0,0,200,200); //Change frame according to your Need
NSString *path = [[NSBundle mainBundle] pathForResource:@"highlighted_image" ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
imageView.image = image;
}
您必须在资源中添加图片..