I would like to change the default UIImage
to highlighted when a UIButton is pressed. So when the below code is executed, I would like to change the UIImage
of another to highlighted.
- (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;
}
UIImage没有突出显示状态(请查看文档: http : //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImage_Class/Reference/Reference.html )
I am assuming that you have the reference of the imageView which You want to highlighed
- (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;
}
You have to add the image in your resource..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.