如果不使用图像?
_t.layer.shadowColor = [UIColor blackColor].CGColor;
_t.layer.shadowOffset = CGSizeMake(-6, -6);
_t.layer.shadowOpacity = 1;
_t.clipsToBounds = false;
这可以创建外部影子。
如果不使用图像?
_t.layer.shadowColor = [UIColor blackColor].CGColor;
_t.layer.shadowOffset = CGSizeMake(-6, -6);
_t.layer.shadowOpacity = 1;
_t.clipsToBounds = false;
这可以创建外部影子。
在状态栏或标签栏下添加阴影视图,这些视图在您的tableView上方。
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
CGFloat tabBarHeight = self.tabBarController.tabBar.bounds.size.height;
// status bar
UIView *statusBarShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, statusBarHeight)];
statusBarShadowView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:statusBarShadowView];
CAGradientLayer *gradientLayer0 = [CAGradientLayer layer];
gradientLayer0.frame = CGRectMake(0, statusBarHeight, self.view.bounds.size.width, 10);
gradientLayer0.colors = @[(id)[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:0.7].CGColor, (id)[UIColor colorWithWhite:1 alpha:0.7].CGColor];
[statusBarShadowView.layer insertSublayer:gradientLayer0 atIndex:0];
// tab bar
UIView *tabBarShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - tabBarHeight, [UIScreen mainScreen].bounds.size.width, tabBarHeight)];
statusBarShadowView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:tabBarShadowView];
CAGradientLayer *gradientLayer1 = [CAGradientLayer layer];
gradientLayer1.frame = CGRectMake(0, -10, self.view.bounds.size.width, 10);
gradientLayer1.colors = @[(id)[UIColor colorWithWhite:1 alpha:0.7].CGColor, (id)[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:0.7].CGColor];
[tabBarShadowView.layer insertSublayer:gradientLayer1 atIndex:0];
我可以只添加到tableview,因为tableview的框架会改变。 –
你可以,但阴影会随着tableview滚动,你会做一些工作来固定阴影位置。 – tomfriwel
我的意思是,它是一个图层,我可以把它放在tableview上,然后它会随着tableview移动。 –
添加视图下方状态栏或标签栏的影子,而这些看法是你的tableView以上。 [statusBar - shadowView - tableView] – tomfriwel