1

私は以下のコードを持っています:

IBOutlet UIImageView *img_Logo;

...

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    CALayer *ca_Logo = img_Logo.layer;
    ca_Logo.position = CGPointMake(400, 400);
    ca_Logo.duration = 2.0f;

    [ca_Logo setNeedsDisplay];

}

タッチイベントがトリガーされるとロゴが消えますが、削除するca_Logo.duration = 2.0fca_Logo移動しますが、アニメーションではなく、すぐに消えて新しい場所に表示されます.

何か問題がありますか?インターフェイスビルダーなしでプログラムする必要がありますかimg_Logo?UIImageViewIBOutlet

CGPointMake(400, 400)画像を からに移動したいCGPointMake(200, 400)

4

2 に答える 2

3

インターフェイスビルダーを使用せずにプログラムする必要があると思いますこのコードを試してください

    UIImage *image = [UIImage imageNamed:@"img_Logo.png"];
CALayer *img = [CALayer layer];
img.contents = (id)image.CGImage;
img.bounds = CGRectMake(0, 0, 100, 200);
img.position = CGPointMake(400, 400);
[self.view.layer addSublayer:img]; 
于 2013-10-25T04:21:29.153 に答える