[英]How to get rid of black line above UITabBar when changing color of tab bar
我有一個代碼可以像這樣更改標簽欄顏色
UITabBar *tabBar = [vc.view.subviews objectAtIndex:1];
CGRect rectAdjust = CGRectMake(roundf(screenWidth - 305.0f) / 2.0f, screenHeight - 54.0f - 10.0f, 305.0f, 54.0f);
tabBar.frame = rectAdjust;
UIColor *tabbarBg = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
tabBar.tintColor = tabbarBg;
代碼應該改變標簽欄的顏色沒有任何缺陷,但是我得到了這個結果
請注意我的標簽欄上方有一條黑線。 我不知道這是從哪里來的。
如何擺脫它?
如果你想刪除UITabBar
頂部的黑線,請使用以下建議,
在項目中添加以下框架
#import <QuartzCore/QuartzCore.h>
並編寫以下代碼
self.tabBar.layer.borderWidth = 0.50;
self.tabBar.layer.borderColor = self.tabBar.tintColor.CGColor;
編輯
我沒試過,但我想@ Nav的評論應該是有用的,如果不是那么使用上面的建議。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.