0

I have a topView on top of a UITableViewCell whose height I increase first, then I'm drawing and removing a shadow to topView with these 2 methods:

- (void)drawShadow
{
    [topView.layer setShadowColor:[UIColor blackColor].CGColor];
    [topView.layer setShadowRadius:3.0];
    [topView.layer setShadowOffset:CGSizeMake(0, 4)];
    [topView.layer setShadowOpacity:0.3];
    [self bringSubviewToFront:topView];
}
- (void)removeShadow
{
    [topView.layer setShadowColor:nil];
    [topView.layer setShadowRadius:0.0];
    [topView.layer setShadowOffset:CGSizeMake(0, 0)];
    [topView.layer setShadowOpacity:0.0];
}

However after shrinking the UITableViewCell back and calling removeShadow, the separator line between each table cell is gone. What's the best way to make it come back?

JackyJohnson
  • 3,106
  • 3
  • 28
  • 35

1 Answers1

0

Have you tried calling

[tableView reloadData];

after removeShadow?

blackcoffee
  • 216
  • 2
  • 7
  • well, I could, and that'd bring the sep line back, but I can't cuz I'm shrinking the cell with an updates block so it kills my animation – JackyJohnson Jul 02 '14 at 17:49
  • So is your block a continuous/long thing? If not you could reload after it's done. If so you might be able to loop through your cells in the update block and select then deselect each one and see if that does the trick. That might be a bit cumbersome though. – blackcoffee Jul 02 '14 at 17:59
  • Well without seeing the other code that is affecting your tableView and cells it is going to be hard to find an elegant solution to this problem. Unless of course there is something obvious we are overlooking :) – blackcoffee Jul 02 '14 at 18:52
  • I'm just flagging the cell's index path whose height I want to increase then I call beginUpdates/endUpdates to animate the height change and drawShadow. When I'm done with that cell and wanna decrease the height back, I un-flag it and make the same updates call then removeShadow. The cell shrinking animation happens, the shadow's removed, the separator line's gone... – JackyJohnson Jul 02 '14 at 19:06
  • It's possible that using beginUpdates/endUpdates to animate it is doing something weird. The documentation does say that they are for "insertion, deletion, and selection calls" https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/beginUpdates You might try using something like UIView's beginAnimations method or a CATransaction similar to http://stackoverflow.com/a/16263150/2661880 and see if you get the line back. – blackcoffee Jul 04 '14 at 01:33