iphone 插入简单动作效果
2011-08-21 13:03 SuperGanker 阅读(69) 评论(0) 收藏 举报加入QuartzCore.framework框架
生成UIImageView 对象
UIImageView *imageView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ballPath.png"]];
设置imageView 的大小和坐标(这里跟随ball对象)
imageView.frame=CGRectMake(ball.center.x-16, ball.center.y-16, 32, 32);
将imageView加入到view,显示。
[self.view addSubview:imageView];
[UIView beginAnimations:nil context:imageView];//开始设置效果 [UIView setAnimationDuration:3.0];//持续时间 [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];//效果 imageView.frame=CGRectMake(ball.center.x-6, ball.center.y-6, 12, 12);//变化后的位置和大小 [imageView setAlpha:0.0];//设置不透明度 [UIView commitAnimations];//合成 [imageView release];//释放imageView
[self.view bringSubviewToFront:ball];