2013-02-21 69 views
1

我在我的iOS應用程序中使用ECSlidingController。我已經檢查過要求和演示。 ECSlidingController以我想要的方式工作,但仍然無法添加任何視圖。使用ECSlidingController時陰影不可見

這裏我做什麼,這是基本視圖控制器(DetailViewController是的UIViewController),這將成爲觸發滑動視圖,它的名字DetailContextViewController(左或右不會在所有問題):

-(void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

    self.view.layer.shadowOpacity = 0.75f; 
    self.view.layer.shadowRadius = 10.0f; 
    self.view.layer.shadowColor = [UIColor blackColor].CGColor; 

    if (![self.slidingViewController.underRightViewController isKindOfClass:[DetailContextViewController class]]) { 
     self.slidingViewController.underRightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailAbout"]; 
    } 
} 

而且這裏是DetailContextViewController(這是一個UIViewController中太):

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.peekLeftAmount = 40.0f; 
    [self.slidingViewController setAnchorLeftPeekAmount:self.peekLeftAmount]; 
    self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth; 
} 

我已經添加QuartCore.h和檢查的TabBar的屬性,即夾子視圖是false。我也試過TableView的影子,所以用self.tableView.layer改變了self.view.layer並且不能再設置陰影。

有什麼不對嗎?

任何幫助將是偉大的。

回答

3

我不知道你在哪裏設置topViewController,但是你需要爲你的topViewController設置陰影參數。例如:

self.slidingViewController.topViewController = newTopViewController; 
newTopViewController.view.layer.shadowOpacity = 0.75f; 
newTopViewController.view.layer.shadowRadius = 10.0f; 
newTopViewController.view.layer.shadowColor = [UIColor blackColor].CGColor; 
+0

這僅僅是我還是會引入驚人數量的視覺延遲/呃逆?我最終渲染了一個影子資產,並將其放置在我的topViewController左側的imageview中。似乎是在iOS 6/7 UIKit上使用陰影圖層的普遍問題。 – Dinkman123 2014-06-24 01:04:17

+0

@ Dinkman123我一直在甩掉我的頭髮來處理同樣的事情。從作者來看,「1.x爲你設置shadowPath,2.x不會」。 https://github.com/ECSlidingViewController/ECSlidingViewController/issues/224 – 2014-09-01 23:10:03

+0

@MarkPhillip我通常避免使用圖層陰影,我在這裏看到性能問題以及許多其他使用內置圖層陰影功能的情況。將自己的陰影渲染爲半透明資源並且性能遠遠優於其他設備非常容易。 – Dinkman123 2014-09-02 23:18:24

2
self.slidingViewController.topViewController = newTopViewController; 
    self.slidingViewController.topViewController.view.layer.shadowOpacity = 0.75f; 
    self.slidingViewController.topViewController.view.layer.shadowRadius = 10.0f; 
    self.slidingViewController.topViewController.view.layer.shadowColor = [UIColor blackColor].CGColor; 

這將是better.Sometimes,newTopViewController是一個UINavigationController。

0

問題可能是topViewController是一個UINavigationController。我有這個相同的問題,並通過添加陰影到UINavigationController視圖而不是UIViewController視圖來修復它。例如,而不是:

self.view.layer.shadowOpacity = 0.75f; 
self.view.layer.shadowRadius = 10.0f; 
self.view.layer.shadowColor = [UIColor blackColor].CGColor; 

做到這一點,而不是:

self.navigationController.view.layer.shadowOpacity = 0.75f; 
self.navigationController.view.layer.shadowRadius = 10.0f; 
self.navigationController.view.layer.shadowColor = [UIColor blackColor].CGColor; 

這是非常簡單的比較,創建你自己的影子層,我還沒有看到任何性能問題。