去除導(dǎo)航欄下面的橫線

在Appdelegate.m里添加以下方法

// 去除導(dǎo)航條黑線

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc]init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

這樣設(shè)置后,雖然去除了導(dǎo)航欄下方的橫線,但是導(dǎo)航欄變成了透明的了。為了保持界面風格的統(tǒng)一,可以把img改成相應(yīng)的顏色;如下

CGSize size =?

UIImage *img = [UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(IPHONE_WIDTH, 1)];

//給UIImage添加的類別

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size

{

@autoreleasepool {

CGRect rect = CGRectMake(0, 0, size.width, size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context,

color.CGColor);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容