我有一個擁有許多子視圖的MainViewController。基本上,它分爲兩個窗格。窗格的設計看起來像剪貼板。我想點擊一個按鈕,讓其中一個剪貼板上的「紙張」進行部分捲曲,以顯示下面的頁面。iOS在UIView上使用部分頁面捲曲,而不是UIViewController
這不是一個完整的Modal ViewController演示情況。
我用下面的代碼的工作,但結果是時髦:
FlipView *flipView = [[FlipView alloc] init];
[self setFlipView:flipView];
[flipView setHidden:YES];
[flipView setFrame:[[self WhereAmI] frame]];
[[self view] addSubview:flipView];
[[self view] bringSubviewToFront:[self WhereAmI]];
[flipView setHidden:NO];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setType:@"pageCurl"];
[animation setFillMode:kCAFillModeForwards];
[animation setEndProgress:0.9];
[animation setRemovedOnCompletion:NO];
[[self WhereAmI] setHidden:YES];
[[[self WhereAmI] layer] addAnimation:animation forKey:@"pageCurlAnimation"];
基本上,我試圖以編程方式加載我的新觀點,在滑動當前可見的觀點背後,然後捲曲將頂端的視圖展現在現在的視圖之下。我得到了一些部分捲曲動畫,但是捲起的「頁面」並不是不透明的,這很奇怪。另外,當我沒有將自己的觀點和標籤設置爲隱藏的時候,即使看到它們捲起來,您仍然可以看到它們「在底下」,這也很奇怪。另外,我沒有看到我放置在XIB中的新視圖的UILabel。
有什麼想法?
謝謝!
好吧,所以我有一個工作解決方案,但它不是我想做的。我仍然很想找出解決我原來的問題,但這裏是我現在正在做的:
- 我的「基」視圖的背景圖像是螺旋裝訂筆記本的圖像。
- 所有其他視圖的背景圖像是頁面捲曲的屏幕截圖。 (通過「背景圖片」,我指的是一個patternImage創建的UIColor。)
過渡意見的代碼是:
- (IBAction)NavigationTabSelected:(id)sender { // Flipping views is driven by a SegmentedControl int selected = [[self NavigationTabsSegmentedControl] selectedSegmentIndex]; int current = [[self ViewArray] indexOfObject:[self ActiveFlipView]]; UIView *newFlip = [[self ViewArray] objectAtIndex:selected]; BOOL up = selected > current; [UIView animateWithDuration:1.0 animations:^{ [UIView setAnimationTransition:(up)?UIViewAnimationTransitionCurlUp:UIViewAnimationTransitionCurlDown forView:[self RightView] cache:YES]; [[self ActiveFlipView] removeFromSuperview]; [[self RightView] addSubview:newFlip]; } completion:^(BOOL finished){ [self setActiveFlipView:newFlip]; }]; }
正如你可以看到,選項卡的權當前標籤生成「捲曲」,並且當前標籤左側的標籤生成「捲曲」。這不是我想要的,但它符合我的目的。
有什麼更好的點子?
你見過UIView的'transitionFromView'和'transitionWithView'方法嗎?你應該能夠在2-3行代碼中做你想做的。 – Rog