fun loadImage(imgView:ImageView,imgURL:NSURL) {
//定义NSURL
//定义NSURLRequest
let
request:
NSURLRequest
=
NSURLRequest
(
URL
:imgURL);
NSURLConnection
.sendAsynchronousRequest(request,queue:
NSOperationQueue
.mainQueue(),
completionHandler: {(response:
NSURLResponse
!,data:
NSData
!,error:
NSError
!)->
Void
in
//将图片数据赋予UIImage
let
img=
UIImage
(data:data);
imgView
.image = img;
})
}
|