如何在图像上应用动画?

发布于 2024-12-09 17:30:11 字数 811 浏览 0 评论 0原文

您好,我正在开发一个应用程序,其中我触摸屏幕的位置会显示图像,此时我正在以这种方式执行此操作。

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *move = [[event allTouches] anyObject];
    CGPoint MovePoint = [move locationInView:self.view];
    appDelegate.FinalMovePoint=MovePoint;   

    timer =[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(Remaing) userInfo:nil repeats:YES];

    [self showImageWithText:@"LongBlue" atPoint:appDelegate.FinalMovePoint];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.1];
    imageView.alpha = 1.0;
    [UIView commitAnimations];
}

在此显示我的图像,但是当调用 NSTimer 时,图像会闪烁或隐藏,我需要图像,直到触摸 -(void)touchesEnded:(NSSet *)touches withEvent:(调用 UIEvent *)event 方法。 请建议我如何完成这项工作。

Hi I am developing a application in which where I touch on screen an image is shown at that point I am doing this in this way.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *move = [[event allTouches] anyObject];
    CGPoint MovePoint = [move locationInView:self.view];
    appDelegate.FinalMovePoint=MovePoint;   

    timer =[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(Remaing) userInfo:nil repeats:YES];

    [self showImageWithText:@"LongBlue" atPoint:appDelegate.FinalMovePoint];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.1];
    imageView.alpha = 1.0;
    [UIView commitAnimations];
}

In this my image is shown but when the NSTimer is called image get blink or get hide I need the image until the touch the -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event method called.
Please suggest me how can I do this work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅的被狗咬 2024-12-16 17:30:12

试试这个。

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *move = [[event allTouches] anyObject];
    CGPoint MovePoint = [move locationInView:self.view];
    appDelegate.FinalMovePoint=MovePoint;   

    timer =[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(Remaing) userInfo:nil repeats:YES];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.1];
    imageView.alpha = 1.0;
    [self showImageWithText:@"LongBlue" atPoint:appDelegate.FinalMovePoint];

    [UIView commitAnimations];
}

Try this.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *move = [[event allTouches] anyObject];
    CGPoint MovePoint = [move locationInView:self.view];
    appDelegate.FinalMovePoint=MovePoint;   

    timer =[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(Remaing) userInfo:nil repeats:YES];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.1];
    imageView.alpha = 1.0;
    [self showImageWithText:@"LongBlue" atPoint:appDelegate.FinalMovePoint];

    [UIView commitAnimations];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文