我想复制他们在导航栏下有一个UIToolbar的AppStore屏幕。发际线已从导航栏中删除,但他们将其用于工具栏。
它看起来是这样的:

为了做到这一点,我将UIToolbar设置为黑色样式+自定义backgroundColor:
[[UIToolbar appearance] setBackgroundColor:[UIColor navBarBackgroundColor]];为了从导航栏中删除发际线,我这样做了:
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init]
forBarMetrics:UIBarMetricsDefault];我得到了这个:

我在想,为了在底部添加一条发际线,我可以创建一个底部有1px线的UIImage,但如果可能的话,我想用其他更好的方式来做。
发布于 2014-07-31 18:36:59
您可以通过将子层添加到工具栏的层来添加底部边框:
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0.0f, toolbar.frame.size.height - 1.0f, toolbar.frame.size.width, 1.0f);
bottomBorder.backgroundColor = [UIColor colorWithWhite:0.8f
alpha:1.0f].CGColor;
[toolbar.layer addSublayer:bottomBorder];https://stackoverflow.com/questions/25056690
复制相似问题