在tips發(fā)表后,有網友回復直接一句代碼去除黑線,過去還真沒試過,受教:
[UITabBar appearance].clipsToBounds = YES;
[UINavigationBar appearance].clipsToBounds = YES;
上面的方法固然漂亮,但對于有些特殊要求的,比如:TabBar中間凸起、以及類似簡書的導航欄頭像縮放伸縮等,就不適用了:GitHub下載地址

效果圖
去除tabbar上的黑線一般做法是在tabbar上覆蓋覆蓋一張背景圖片,具體代碼,在自定義Tabbar里的didload方法里添加,如下代碼
- (void)viewDidLoad
{
[super viewDidLoad];
//設置tabbar背景顏色
[[UITabBar appearance] setBackgroundColor:[UIColor whiteColor]];
[[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setTintColor:ButtonColor];
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbarImage.png"]];
// [UITabBar appearance].clipsToBounds = YES; // 添加的圖片大小不匹配的話,加上此句,屏蔽掉tabbar多余部分
[[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"tabbarImage.png"]];
}
導航NavigationBar的黑線條,去除相對容易,如果需要全局的,只需,在AppDelegate的didFinishLaunchingWithOptions方法中添加兩行代碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
return YES;
}