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