3
A
回答
16
我認爲你正在尋找的唯一事情是:
的UIView的
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
和
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
這些動畫過渡只能在動畫塊中使用。轉換在容器視圖上設置,然後舊視圖換出新視圖,然後提交動畫。
喜歡:
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourContainerView cache:YES];
[yourContainerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
0
把你的UIImageView到一個UIView,並使用此代碼(從實用的應用項目,樣品)
- (void)loadFlipsideViewController {
FlipsideViewController *viewController = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
self.flipsideViewController = viewController;
[viewController release];
// Set up the navigation bar
UINavigationBar *aNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
aNavigationBar.barStyle = UIBarStyleBlackOpaque;
self.flipsideNavigationBar = aNavigationBar;
[aNavigationBar release];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(toggleView)];
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"Test123"];
navigationItem.rightBarButtonItem = buttonItem;
[flipsideNavigationBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];
[buttonItem release];
}
- (IBAction)toggleView {
/*
This method is called when the info or Done button is pressed.
It flips the displayed view from the main view to the flipside view and vice-versa.
*/
if (flipsideViewController == nil) {
[self loadFlipsideViewController];
}
UIView *mainView = mainViewController.view;
UIView *flipsideView = flipsideViewController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];
if ([mainView superview] != nil) {
[flipsideViewController viewWillAppear:YES];
[mainViewController viewWillDisappear:YES];
[mainView removeFromSuperview];
[infoButton removeFromSuperview];
[self.view addSubview:flipsideView];
[self.view insertSubview:flipsideNavigationBar aboveSubview:flipsideView];
[mainViewController viewDidDisappear:YES];
[flipsideViewController viewDidAppear:YES];
} else {
[mainViewController viewWillAppear:YES];
[flipsideViewController viewWillDisappear:YES];
[flipsideView removeFromSuperview];
[flipsideNavigationBar removeFromSuperview];
[self.view addSubview:mainView];
[self.view insertSubview:infoButton aboveSubview:mainViewController.view];
[flipsideViewController viewDidDisappear:YES];
[mainViewController viewDidAppear:YES];
}
[UIView commitAnimations];
}
0
MAINVIEW和flipToView是imageViews的目的和containerView是UIView的的對象。
下面給出兩個示例代碼捲曲的ImageView和翻轉的ImageView從左至右
- (void)curlAction:(id)sender { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown)forView:containerView cache:YES]; if ([flipToView superview]) { [flipToView removeFromSuperview]; [containerView addSubview:mainView]; } else { [mainView removeFromSuperview]; [containerView addSubview:flipToView]; } [UIView commitAnimations]; }
,並從左至右這裏的代碼
- (void)flipAction:(id)sender { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:containerView cache:YES]; if ([flipToView superview]) { [flipToView removeFromSuperview]; [containerView addSubview:mainView]; } else { [mainView removeFromSuperview]; [containerView addSubview:flipToView]; } [UIView commitAnimations]; }
感謝帶來的圖像& Regards
0
另一個解決方案可在我的repo,但它不會涉及動畫呢!它只操作圖像方向來提供一些圖像效果,即垂直/水平翻轉和左右旋轉90度。
相關問題
- 1. 如何strel UIImageView(iPhone開發)?
- 2. 如何翻轉UIImageView?
- 3. iPhone動畫,如何翻轉硬幣(2 UIImageview)?
- 4. 問題翻轉UIImageView
- 5. UIViewAnimationTransition翻轉的UIImageView
- 6. iPhone UIButton翻轉和展開
- 7. 我如何在cocos2d中水平翻轉水平對於iphone
- 8. 如何翻轉ByteBuffer相對於標記?
- 9. 使用objective-c翻轉UIImageView
- 10. 使用塊翻轉UIImageView
- 11. iPhone開發自定義形UIImageview
- 12. iPhone開發 - 的UIImageView內存問題
- 13. iphone的UIImageView旋轉
- 14. iPhone:如何左右旋轉UIImageView?
- 15. Iphone翻轉UIimages
- 16. iPhone - 翻轉UIImage
- 17. 如何在iphone應用程序開發中使用UIImageView?
- 18. 對於iPhone開發,strncpy是否安全?
- 19. iPhone翻轉右鍵(如iTunes)
- 20. 使用的UIImageView適用於iPhone翻書動畫
- 21. 如何在iPhone SDK中翻轉按鈕?
- 22. 如何翻轉iphone前置攝像頭
- 23. UIImageView的開始動畫沒有動畫翻轉圖像
- 24. 翻譯UIImageView Up
- 25. IPHONE UIIMAGEVIEW無法發佈?
- 26. 使用NSTimer旋轉和翻譯UIImageView
- 27. iOS版:翻轉的UIImageView到的UITableView
- 28. 旋轉和翻譯UIImageView在屏幕上
- 29. 使用翻轉動畫動畫UIImageView
- 30. iOS翻轉UIImageView 180度(不是動畫)
發現錯字。應該是「exchangeSubviewAtIndex」而不是「exchangeSubviewsAtIndex」。謝謝。 – bentford 2009-04-28 22:40:49