내비게이션 표시줄의 밑줄을 없애다

1283 단어
이전에 빈 이미지를 만들어서 UINavigationBar에 값을 부여하는 shadow Image를 만드는 방법은 소용이 없습니다. 그러면 UINavigationBar의 shadow Image에 투명한 이미지나 내비게이션 표시줄과 같은 색의 그림을 설정합니다.코드는 다음과 같습니다.
//     UINavigationBar category,      :
//     
#define NavBar_width [UIScreen mainScreen].bounds.size.width
#define NavBar_height 1
//        
-(void)clearShadowImageWithImage:(UIImage*)image {
    
    UIGraphicsBeginImageContext(CGSizeMake(NavBar_width, NavBar_height));
    
    [image drawInRect:CGRectMake (0, 0, NavBar_width, NavBar_height)];
    
    image = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext ();
    
    self.shadowImage = image;
}

//        
- (void)clearShadowImageWithColor:(UIColor*)color {
    self.shadowImage = [self imageWithColor:color];
}
- (UIImage*)imageWithColor:(UIColor*)color {
    if (!color) color = [UIColor clearColor];
    
    UIGraphicsBeginImageContext(CGSizeMake(NavBar_width, NavBar_height));
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, CGRectMake (0 ,0 , NavBar_width, NavBar_height));
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}

좋은 웹페이지 즐겨찾기