我有一个 UIView,我使用情节提要将它设置为我的 tableView 的 tableHeaderView。
我在 viewDidLoad 期间使用以下代码给这个 UIView 一个阴影:
_viewHeaderInfo.layer.masksToBounds = NO;
_viewHeaderInfo.layer.shadowOffset = CGSizeMake(0, 2);
_viewHeaderInfo.layer.shadowOpacity = 0.5;
当我在 iPhone 6.0 模拟器中运行它时,阴影会显示出来。当我在 iPhone 5.1 模拟器中运行它时,阴影不显示。
这不是显示阴影的方式吗?我应该采取不同的做法吗?提前致谢!
附加信息:
我有一些代码可以在某些用户操作上使用动画来隐藏/显示视图。显示视图时(先隐藏它之后),我注意到只要动画运行,阴影就会显示。在动画结束时,阴影再次消失。这是显示视图的动画代码:
// Get references //
CGFloat h = _viewHeaderInfo.bounds.size.height;
UITableView *tv = self.tableView;
// Move the frame of the View UP by changing the .y value //
_viewHeaderInfo.frame = CGRectMake(0, -h, tv.frame.size.width, h);
// Start animation: adding the View to .tableHeaderView resets the View.frame.y to 0 //
[UIView animateWithDuration:0.3 animations:^{
[tv scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
tv.tableHeaderView = _viewHeaderInfo;
}];