0
我想讓我的照片庫像本書的頁面一樣動畫。 有沒有用,我既可以在左側或右側使用UIanimationtransitioncurl任何方法?我想使用UIanimationtransitioncurl右側或左側使用動畫進行圖像查看。可能嗎?
這是代碼,你建議我。我已經完成了viewdidload方法的分配。
self.title = @"TransitionsTitle";
// Create the container view which we will use for transition animation (centered horizontally).
CGRect frame = CGRectMake(round((self.view.bounds.size.width - kImageWidth)/2.0),
kTopPlacement, kImageWidth, kImageHeight);
self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:self.containerView];
// The container view can represent the images for accessibility.
[self.containerView setIsAccessibilityElement:YES];
[self.containerView setAccessibilityLabel:NSLocalizedString(@"ImagesTitle", @"")];
// Create the initial image view.
frame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
self.mainView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
self.mainView.image = [UIImage imageNamed:@"scene1.jpg"];
[self.containerView addSubview:self.mainView];
// Create the alternate image view (to transition between).
CGRect imageFrame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
self.flipToView = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
self.flipToView.image = [UIImage imageNamed:@"scene2.jpg"];
CGAffineTransform rotate=CGAffineTransformMakeRotation(3.14/2);
[containerView setTransform:rotate];
[self.view addSubview:containerView];
rotate=CGAffineTransformMakeRotation(-3.14/2);
[mainView setTransform:rotate];
[self.containerView addSubview:mainView];
[self.mainView addSubview:flipToView];
//我已將它放在按鈕操作事件上。
- (IBAction)flipAction:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:4];
[UIView setAnimationTransition:([self.mainView superview] ?
UIViewAnimationTransitionCurlDown : UIViewAnimationTransitionCurlDown)
forView:self.containerView cache:YES];
if ([flipToView superview])
{
[self.flipToView removeFromSuperview];
[self.containerView addSubview:mainView];
}
else
{
[self.mainView removeFromSuperview];
[self.containerView addSubview:flipToView];
}
[UIView commitAnimations];
}
嗨,你應該從我在viewDidLoad方法,而不是在行動本身第一個答案粘貼代碼(旋轉編碼)的第一部分。 – shannoga 2011-01-25 06:21:36
您好,我仍然完成它沒有顯示你在談論的設定偏移你能幫助我,它是如何影響到動畫的結果呢? – NIKHIL 2011-01-25 06:56:11