You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: iOS/NameGame/NameGame/ImageUtils.swift
+18-10Lines changed: 18 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -8,24 +8,32 @@
8
8
9
9
import Foundation
10
10
import UIKit
11
+
import main
11
12
12
13
publicextensionUIImageView{
13
-
func downloaded(from url:URL, contentMode mode:UIView.ContentMode=.scaleAspectFit){ // for swift 4.2 syntax just use ===> mode: UIView.ContentMode
14
+
func downloaded(from url:URL, contentMode mode:UIView.ContentMode=.scaleAspectFit, onComplete:@escaping()->()){ // for swift 4.2 syntax just use ===> mode: UIView.ContentMode
14
15
contentMode = mode
15
16
URLSession.shared.dataTask(with: url){ data, response, error in
16
17
guard
17
-
let httpURLResponse = response as?HTTPURLResponse, httpURLResponse.statusCode ==200,
18
-
let mimeType = response?.mimeType, mimeType.hasPrefix("image"),
19
-
let data = data, error ==nil,
20
-
let image =UIImage(data: data)
21
-
else{return}
18
+
let httpURLResponse = response as?HTTPURLResponse, httpURLResponse.statusCode ==200,
19
+
let mimeType = response?.mimeType, mimeType.hasPrefix("image"),
func downloaded(from link:String, contentMode mode:UIView.ContentMode=.scaleAspectFit){ // for swift 4.2 syntax just use ===> mode: UIView.ContentMode
28
-
guardlet url =URL(string: link)else{return}
29
-
downloaded(from: url, contentMode: mode)
32
+
33
+
func downloaded(from link:String, contentMode mode:UIView.ContentMode=.scaleAspectFit, onComplete:@escaping()->()){ // for swift 4.2 syntax just use ===> mode: UIView.ContentMode
0 commit comments