专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 图形/图像

兑现UIImage的移动动画

发布时间:2011-06-27 20:28:53 文章来源:www.iduyao.cn 采编人员:星星草
实现UIImage的移动动画

- (void)viewDidLoad
{
    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    image = [UIImage imageNamed:@"apple.png"];
    imageView.image = image;
    [self.view addSubview:imageView];

}

 

触屏获得接触点的坐标

 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event  
{
    UITouch *touch = [touches anyObject];
    point = [touch locationInView:self.view];
    [self imageMoveOne:point.x imageMoveTwo:point.y];
}

 

开始移动

 

- (void)imageMoveOne:(CGFloat)x imageMoveTwo:(CGFloat)y
{
    [UIImageView beginAnimations:nil context:NULL];
    UIImageView.animationDuration = 5;
    UIImageView.animationRepeatCount = 0;
    [imageView setFrame:CGRectMake(x, y, 100, 100)];
    [UIImageView commitAnimations];
    
}
 
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: