marinofaggiana 4 жил өмнө
parent
commit
200cccaae0

+ 2 - 3
iOSClient/Settings/CCManageAccount.m

@@ -60,9 +60,8 @@
         if (avatar) {
             
             avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(35, 35) isAspectRation:YES];
-            
-            CCAvatar *avatarImageView = [[CCAvatar alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
-            
+            NCAvatar *avatarImageView = [[NCAvatar alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
+                        
             CGSize imageSize = avatarImageView.bounds.size;
             UIGraphicsBeginImageContextWithOptions(imageSize, NO, UIScreen.mainScreen.scale);
             CGContextRef context = UIGraphicsGetCurrentContext();

+ 0 - 6
iOSClient/Utility/CCGraphics.h

@@ -37,9 +37,3 @@
 + (void)settingThemingColor:(NSString *)themingColor themingColorElement:(NSString *)themingColorElement themingColorText:(NSString *)themingColorText;
 
 @end
-
-@interface CCAvatar : UIImageView
-
-- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth;
-
-@end

+ 0 - 24
iOSClient/Utility/CCGraphics.m

@@ -248,27 +248,3 @@
 }
 
 @end
-
-// ------------------------------------------------------------------------------------------------------
-// MARK: Avatar
-// ------------------------------------------------------------------------------------------------------
-
-@implementation CCAvatar
-
-- (id)initWithImage:(UIImage *)image borderColor:(UIColor*)borderColor borderWidth:(float)borderWidth
-{
-    self = [super initWithImage:image];
-    
-    float cornerRadius = self.frame.size.height/2.0f;
-    CALayer *layer = [self layer];
-        
-    [layer setMasksToBounds:YES];
-    [layer setCornerRadius: cornerRadius];
-    [layer setBorderWidth: borderWidth];
-    [layer setBorderColor:[borderColor CGColor]];
-    
-    return self;
-}
-
-@end
-

+ 9 - 0
iOSClient/Utility/NCAvatar.swift

@@ -58,6 +58,15 @@ import Foundation
         super.init(frame: frame)
     }
     
+    @objc init(image: UIImage?, borderColor: UIColor, borderWidth: CGFloat) {
+        super.init(image: image)
+        
+        self.borderColor = borderColor
+        self.borderWidth = borderWidth
+        
+        layoutSubviews()
+    }
+
     override func layoutSubviews() {
         super.layoutSubviews()
         

+ 2 - 2
iOSClient/Utility/NCUtility.swift

@@ -448,9 +448,9 @@ class NCUtility: NSObject {
         UIGraphicsEndImageContext()
 
         UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
-        let avatarImageView = CCAvatar.init(image: image, borderColor: .lightGray, borderWidth: Float(1 * UIScreen.main.scale))
+        let avatarImageView = NCAvatar.init(image: image, borderColor: .lightGray, borderWidth: UIScreen.main.scale)
         guard let context = UIGraphicsGetCurrentContext() else { return nil }
-        avatarImageView?.layer.render(in: context)
+        avatarImageView.layer.render(in: context)
         guard let imageAvatar = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
         UIGraphicsEndImageContext()