Marino Faggiana 6 years ago
parent
commit
c34714d6fb

+ 7 - 1
iOSClient/Offline/NCOffline.swift

@@ -619,7 +619,13 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
             cell.labelTitle.text = metadata.fileNameView
             
             if metadata.directory {
-                cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+//                cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+                
+                let image = UIImage.init(named: "folder")!
+                
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image.size.width, height: image.size.height, color: NCBrandColor.sharedInstance.brandElement)
+                
+                
             } else {
                 cell.imageItem.image = image
             }

+ 1 - 0
iOSClient/Utility/CCGraphics.h

@@ -39,6 +39,7 @@
 
 + (UIColor *)colorFromHexString:(NSString *)hexString;
 + (UIImage *)changeThemingColorImage:(UIImage *)image multiplier:(NSInteger)multiplier color:(UIColor *)color;
++ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height color:(UIColor *)color;
 
 + (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont;
 

+ 14 - 0
iOSClient/Utility/CCGraphics.m

@@ -216,6 +216,20 @@
     return [UIImage imageWithCGImage:img.CGImage scale:2.0 orientation: UIImageOrientationDownMirrored];
 }
 
++ (UIImage *)changeThemingColorImage:(UIImage *)image width:(CGFloat)width height:(CGFloat)height color:(UIColor *)color
+{
+    CGRect rect = CGRectMake(0, 0, width, height);
+    UIGraphicsBeginImageContext(rect.size);
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    CGContextClipToMask(context, rect, image.CGImage);
+    CGContextSetFillColorWithColor(context, [color CGColor]);
+    CGContextFillRect(context, rect);
+    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+    
+    return [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
+}
+
 + (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont
 {
     NSDictionary* attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:sizeOfFont], NSForegroundColorAttributeName:colorText};