######最近公司出了這樣一個(gè)需求,說(shuō)是要修改Navigation Bar下邊細(xì)線顏色,我上網(wǎng)Google和百度都沒(méi)有找到合適的方法,于是自己想了一個(gè)臨時(shí)的方法。原理:navigation bar也是View的子類,那就可以使用addSubview:方法,所以直接覆蓋原來(lái)的線就好了,直接上代碼吧。
# 更改控制器下邊細(xì)線的顏色
```?
[CGSize naviBarSize =self.navigationController.navigationBar.frame.size;
UIImageView *lineImageView = [[UIImageViewalloc]initWithFrame:CGRectMake(0, naviBarSize.height-.5, naviBarSize.width,1)];
lineImageView.backgroundColor= [UIColorwhiteColor];
lineImageView.image= [[UIImageimageNamed:@"nav_border_line.png"]stretchableImageWithLeftCapWidth:10topCapHeight:0.5];
[self.navigationController.navigationBaraddSubview:lineImageView]; ]?
``` ??
# tab bar上邊細(xì)線的顏色更改
```?
UIImageView*lineView = [[UIImageViewalloc]initWithFrame:CGRectMake(0, -0.5,self.tabBarController.tabBar.frame.size.width,1)];
lineView.backgroundColor= [UIColor whiteColor];
lineView.image= [[UIImageimageNamed:@"nav_border_line.png"]stretchableImageWithLeftCapWidth:10topCapHeight:0.5];
[self.tabBarController.tabBar addSubview:lineView];?
```
####說(shuō)明
- 1、nav_border_line.png這個(gè)就是帶顏色的細(xì)線切圖 高度是1px
- 2、如果使用View覆蓋,如果顏色比系統(tǒng)的默認(rèn)顏色淺,無(wú)法覆蓋,最好選擇ImageView并且imageView的背景顏色設(shè)置為白色