[英]UICollectionViewCell pushed down when embedded in navigation controller
[英]Views getting darker when are pushed on navigation controller
我通過segues在NavigationController上推送ViewControllers。 我有自己的子類NavigationController,已在索引0處插入UIImageView
它是整個應用程序的背景。
問題是我可以看到,當新的視圖控制器從右側進入屏幕時,一開始就像是有一些淺黑的覆蓋層,在調用viewDidApear
之后消失了。
每個視圖控制器都有一個self.view.backgroundColor = [UIColor clearColor]
。 如果我暫時更改它,一切都很好。 也許我應該以其他方式設置應用程序背景? 如果沒有,如何避免這種發黑現象?
在這里,您將獲得具有這種效果的屏幕截圖: http : //tinypic.com/r/34j9ffs/8
這是因為iOS 7中使用了標准的UINavigationController
推送動畫。將新的VC推送到堆棧上時,它將自身覆蓋在先前VC的頂部,並在其下面有一個陰影。 這樣,當您推送具有清晰背景的viewControllers時,過渡發生時您會看到陰影。
有兩種可能的解決方案:
UINavigationController
類別以添加更簡單的“復古”推送和彈出動畫。 這更像是一種快速而棘手的解決方案。 我創建了一個應該執行此任務的自定義推送序列:
ClearBkgPushSegue.h:
#import <UIKit/UIKit.h>
@interface ClearBkgPushSegue : UIStoryboardSegue
@end
ClearBkgPushSegue.m:
#import "ClearBkgPushSegue.h"
@implementation ClearBkgPushSegue
-(void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
CGRect bounds = [[UIScreen mainScreen] bounds];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIView *destView = destinationViewController.view;
[window insertSubview:destinationViewController.view aboveSubview:sourceViewController.view];
destView.frame = CGRectMake(bounds.size.width, destView.frame.origin.y, destView.frame.size.width, destView.frame.size.height);
[UIView animateWithDuration:.35 delay:0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
destView.frame = sourceViewController.view.frame;
sourceViewController.view.frame = CGRectMake([UIScreen mainScreen].bounds.size.width * -0.33, 0.0, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);
sourceViewController.view.alpha = 0;
} completion:^(BOOL finished) {
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
sourceViewController.view.alpha = 1;
}];
}
@end
只需選擇要“自定義”的選項,然后選擇該課程,您就可以開始了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.