1
我试图为一个按钮设置动画。该按钮将以0和0的高度和宽度开始并扩展到其预期大小的100%。然后它会缩小到其尺寸的80%,然后再回到100%。在没有明确定义CGRect的情况下缩小一个框架80%
有没有办法做到这一点,而不必明确计算每个职位的CGRect?问题在于,在80%时,框架与100%框架的位置不完全对齐。我必须手动计算帧的x和y位置,这是很耗时间的,因为我正在为很多按钮执行此操作。
这里就是我目前正在做的事:
CGRect smallPlay = CGRectMake(PlayButton.frame.origin.x + 94, PlayButton.frame.origin.y + 23, 0, 0);
CGRect almostFullPlay = CGRectMake(40, 170, 160, 30);
[UIView animateWithDuration:0.3
delay:0
options: UIViewAnimationCurveEaseOut
animations:^{
PlayButton.frame = smallPlay;
PlayButton.frame = CGRectMake(50, 178, 187, 45);
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.2
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
PlayButton.frame = almostFullPlay;
PlayButton.frame = CGRectMake(50, 178,187, 45);
} completion:^(BOOL finished){
NSLog(@"Done!");
}
];
}];
编辑:我知道我可以写一个函数在80%来计算的框架,但我想知道如果有一个更好的办法这样做不需要我额外写任何东西。
非常感谢!这正是我所期待的。 – 2012-08-03 03:26:53