您的位置:首页 > 产品设计 > UI/UE

UIView动画设置

2014-03-22 15:15 302 查看
- (void)loadView
{

//将viewController的根view初始化

self.view = [[[UIView
alloc] initWithFrame:CGRectMake(0,
0, 320,
480)]
autorelease];

self.view.backgroundColor = [UIColor
whiteColor];

_imgView = [[UIImageView
alloc] initWithFrame:CGRectMake(10,
20,
100, 200)];

_imgView.image = [UIImage
imageNamed:@"iphone.png"];
[self.view
addSubview:_imgView];
[_imgView
release];

UIButton *btn = [UIButton
buttonWithType:UIButtonTypeRoundedRect];
btn.frame =
CGRectMake(320-100,
30, 100,
30);

[btn setTitle:@"ani"
forState:UIControlStateNormal];

[btn addTarget:self
action:@selector(animationAction:)
forControlEvents:UIControlEventTouchUpInside];
[self.view
addSubview:btn];

}

-(void)animationAction:(id)sender
{

//动画块开始

[UIView
beginAnimations:nil
context:nil];

[UIView
setAnimationDuration:0.65f];//设置动画时间

[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView
setAnimationRepeatCount:1];

//设置动画转变方式

[UIView
setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:_imgView
cache:YES];

//[UIView setAnimationDelegate:self];//设置动画代理

//[UIView setAnimationWillStartSelector:@selector()]

//[UIView setAnimationDidStopSelector:@selector(animationDidStop)];

//_imgView.frame = CGRectMake(10, 20, 10, 20);

//_imgView.alpha = 0.0;

//_imgView.hidden = YES;

//旋转

/*

CGAffineTransform newTransForm = CGAffineTransformRotate(_imgView.transform, M_PI_4);

_imgView.transform = newTransForm;

*/

//缩放

/*

//CGAffineTransform newTrans =CGAffineTransformMakeScale(0.7, 0.7);

CGAffineTransform newTrans = CGAffineTransformScale(_imgView.transform, 0.9, 0.9);

_imgView.transform = newTrans;

*/

//位移

//CGAffineTransform newTrans = CGAffineTransformMakeTranslation(100, 100);

CGAffineTransform newTrans =
CGAffineTransformTranslate(_imgView.transform,
10,
10);

_imgView.transform = newTrans;

[UIView
commitAnimations];

}

-(void)animationDidStop
{

[UIView
beginAnimations:nil
context:nil];

[UIView
setAnimationDuration:0.35f];//设置动画时间

[UIView
setAnimationCurve:UIViewAnimationCurveEaseInOut];

_imgView.frame =
CGRectMake(10,
20, 100,
200);

//_imgView.alpha = 1.0f;

_imgView.hidden =
NO;

[UIView
commitAnimations];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: