我在我的應用程序中有一個頁面,其中有一個用戶的個人資料圖片作爲其在Twitter個人資料頁面中的圓圈。ios動畫圖像從圓圈內擴展
我必須添加一個功能,當我點擊它時,圖像應該展開。需要添加動畫,以便從較小的圓的中心慢慢出現一個新的大圓,併到達屏幕的中心。
有關如何實現這一點的任何想法?
我在我的應用程序中有一個頁面,其中有一個用戶的個人資料圖片作爲其在Twitter個人資料頁面中的圓圈。ios動畫圖像從圓圈內擴展
我必須添加一個功能,當我點擊它時,圖像應該展開。需要添加動畫,以便從較小的圓的中心慢慢出現一個新的大圓,併到達屏幕的中心。
有關如何實現這一點的任何想法?
嘗試UIView Animation
改變大圓的位置,大小,alpha和圓角半徑(如果需要)的塊。
將較大的圓圈(最初尺寸較小)放置在較小的圓圈頂部並最初隱藏起來。然後動畫之前,取消隱藏,並使用塊這樣的動畫:
[UIView animateWithDuration:1.0 animations:^{
// set bigger circle destination position i.e. centre of screen
// set bigger circle final size
// set other properties like alpha, corner radius etc
} completion:nil];
使用CATransform3DScale
變換和UIView Animation
CATransform3D avatarTransform = CATransform3DIdentity;
avatarTransform = CATransform3DScale(avatarTransform, avatarScaleFactor,avatarScaleFactor, 0);
[UIView animateWithDuration:1.0 animations:^{
//Change the frame to reach the center of screen
self.avatar.layer.transform = headerTransform
} completion:nil]
感謝您的建議。但是,我不必爲同一個圖像視圖設置動畫。 –
您可以簡單地使用CGAffineTransformScale
和擴展您的ImageView的UIView的animateWithDuration塊內。
imgV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0, 0.0);
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut
animations:^{
imgV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
}
completion:^(BOOL finished) {
NSLog(@"done");
}];
如需進一步的參考,你可以看看到這些問題#1:
感謝您的建議。但是,我不必爲同一個圖像視圖設置動畫。 –
非常感謝您的建議! –
歡迎您:) – Maverick