0

View に imageView がいくつかありますが、imageView の画像の background.color を変更したいと考えています。同じ imageView を 2 回クリックすると、最初の画像に変わります。

どうすればこれを行うことができますか?

4

2 に答える 2

0

変数を使用して、ImageView が何回触れられたかを確認できます。これは次のように変更できます:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch *touch = [touches anyObject];
    if (touch.view == imageView) {
        // Make that variable ++;
        if (variable == 2){
            imageView.image = [UIImage imageNamed:@"a.png"];
        }
    }
}
于 2013-08-02T13:49:52.817 に答える