0

It's funny, I've got it working properly in one of the child table views but for some reason it isn't showing up in my main menuTableView.

This is how I've set it up in Storyboard:

enter image description here

And this is the code that I'm working with for shadow additions:

self.menuTableView.layer.shadowColor = [UIColor blackColor].CGColor;
self.menuTableView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f);
self.menuTableView.layer.shadowOpacity = 0.8;
self.menuTableView.layer.shadowRadius = 1.5f;
self.menuTableView.clipsToBounds = NO;
self.menuTableView.layer.masksToBounds = NO;

I basically want to add a drop shadow to the bottom and top of the tableview. Help would be appreciated! Thank you!

UPDATED: Please note that although I know that tons of questions similar to mine exist, most of them just forgot to set the clipsToBounds and masksToBounds to NO. Where as I already have that, and yet it works on one tableview but not my main one, which no question on here can answer, and I haven't been able to find anything on it since everything seems to be correctly coded. Thank you.

KingPolygon
  • 4,753
  • 7
  • 43
  • 72
  • 2
    There are multiple questions about this already. Please search prior to adding a question. http://stackoverflow.com/questions/9089789/adding-drop-shadow-to-uitableview-doesnt-work-properly http://stackoverflow.com/questions/9012071/adding-drop-shadow-to-uitableview – Mark McCorkle Jun 04 '13 at 20:51
  • Thank you DCGoD, however none of those questions answer mine. In fact, my problem isn't the same as those questions, my clipsToBound is already set to NO, so please tell me how those answers help me? Thanks for your time though. – KingPolygon Jun 04 '13 at 20:54
  • Where are you adding your code? You need to make sure to add it after the tableView is rendered. Perhaps in your viewWillAppear or viewDidAppear. Although, people offer solutions in those questions by simply placing the tableView in a UIView and adding a shadow to that UIView. – Mark McCorkle Jun 04 '13 at 20:56
  • Yupp I have it inside a view and added the shadow to the view, but nothing. I'm adding it inside viewDidLoad. Could that be the problem, I'll try viewDidAppear. Thank you for helping out. EDIT: Tried it out in viewWillAppear and viewDidAppear but it still won't appear... hmm. – KingPolygon Jun 04 '13 at 21:00
  • I think you're missing the point of the UIView. Add the shadow to the UIView itself and then add the UITableView as a subview to the UIView. Start by adding the shadow to the UIView first, test, then add the UITableView if you think that's causing issues. – Mark McCorkle Jun 04 '13 at 21:07

1 Answers1

1

First add a separate UIView that will act as a container to your UITableView. Add the shadow to that UIView. Then add your UITableView with the same frame size as a subview of that UIView to achieve the effect you're looking for.

Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42