2012-12-06 64 views
0

我想做一個乾淨的白色設計。所以,我將tintColor屬性設置爲whiteColor,但在UINavigationBarUISearchBar下有這些黑線。刪除導航欄/搜索欄底部的黑線

做一些人知道,如何去除黑暗的線條或如何改變顏色?

回答

1

這是我做的,似乎工作,它是這個環節的進一步發展。我改變了明確的寬度聲明一個動態的,所以,這將是該視圖的大小,如果你改變視圖大小與否:

UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, self.view.frame.size.width, 1)]; 
[overlayView setBackgroundColor:[UIColor whiteColor]]; 
[navBar addSubview:overlayView]; // navBar is your UINavigationBar instance 
[overlayView release]; 

我發現這裏的東西: How to remove UINavigatonItem's border line

3

添加方法的UIImage按類別

+ (UIImage *)imageWithColor:(UIColor *)color { 
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); 
    UIGraphicsBeginImageContext(rect.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(context, [color CGColor]); 
    CGContextFillRect(context, rect); 
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return theImage; 
} 

和剛剛成立

[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor whiteColor]]]; 
+2

或self.navigationController.navigationBar.shadowImage = [UIImage new]; – Caroline

+0

@Caroline如果在故事板中,如何刪除導航欄底線? – aircraft

0

從iOS 7 UINavigationBar有一個shadowImage屬性,您可以將其設置爲nil。