Kaynağa Gözat

Remove iOS 11 navigation bar bottom line

Marino Faggiana 7 yıl önce
ebeveyn
işleme
1d5d3390b7

+ 6 - 0
iOSClient/Main/CCMain.m

@@ -162,6 +162,9 @@
     // Pull-to-Refresh
     [self createRefreshControl];
     
+    // Remove iOS 11 navigation bar bottom line
+    self.navigationController.navigationBar.shadowImage = [CCGraphics generateSinglePixelImageWithColor:[NCBrandColor sharedInstance].brand];
+    
     // Register for 3D Touch Previewing if available
     if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)] && (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable))
     {
@@ -319,6 +322,9 @@
     // color searchbar
     self.searchController.searchBar.barTintColor = [NCBrandColor sharedInstance].brand;
     
+    // Remove iOS 11 navigation bar bottom line
+    self.navigationController.navigationBar.shadowImage = [CCGraphics generateSinglePixelImageWithColor:[NCBrandColor sharedInstance].brand];
+    
     // Reload Table View
     [self tableViewReloadData];
 }

+ 2 - 0
iOSClient/Utility/CCGraphics.h

@@ -48,6 +48,8 @@
 
 + (BOOL)isLight:(UIColor *)color;
 
++ (UIImage *)generateSinglePixelImageWithColor:(UIColor *)color;
+
 @end
 
 @interface CCAvatar : UIImageView

+ 22 - 0
iOSClient/Utility/CCGraphics.m

@@ -387,6 +387,28 @@ Color difference is determined by the following formula:
     
     return grayscaled;
 }
+
++ (UIImage *)generateSinglePixelImageWithColor:(UIColor *)color
+{
+    CGSize imageSize = CGSizeMake(1.0f, 1.0f);
+    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0f);
+    
+    CGContextRef theContext = UIGraphicsGetCurrentContext();
+    CGContextSetFillColorWithColor(theContext, color.CGColor);
+    CGContextFillRect(theContext, CGRectMake(0.0f, 0.0f, imageSize.width, imageSize.height));
+    
+    CGImageRef theCGImage = CGBitmapContextCreateImage(theContext);
+    UIImage *theImage;
+    if ([[UIImage class] respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) {
+        theImage = [UIImage imageWithCGImage:theCGImage scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
+    } else {
+        theImage = [UIImage imageWithCGImage:theCGImage];
+    }
+    CGImageRelease(theCGImage);
+    
+    return theImage;
+}
+
 @end
 
 // ------------------------------------------------------------------------------------------------------