swift 同步加载图片

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
self.window!.backgroundColor = UIColor.whiteColor() self.window!.rootViewController = RootViewController(); self.window!.makeKeyAndVisible()
return true
}
}
import UIKit

class RootViewController: UIViewController {

    override func viewDidLoad() {
super.viewDidLoad() let imageView = UIImageView.init(frame: UIScreen.mainScreen().bounds);
imageView.backgroundColor = UIColor.greenColor()
self.view.addSubview(imageView) let url:NSURL = NSURL.init(string: "http://pic2.ooopic.com/11/86/60/84bOOOPIC13.jpg")!
let data:NSData = NSData(contentsOfURL: url)!
let image = UIImage(data: data)!
imageView.image = image } }
上一篇:为Hadoop集群选择合适的硬件配置


下一篇:第二十次codeforces竞技结束 #276 Div 2