0

我想在UIImage按下 UIButton 时将默认值更改为突出显示。因此,当执行以下代码时,我想将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;
  }
4

2 回答 2

0

UIImage 没有突出显示的状态(查看文档:http: //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/Reference/Reference.html

于 2013-06-22T15:51:35.087 回答
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;
    }

您必须在资源中添加图像..

于 2013-06-22T15:53:24.400 回答