Added Swift example to README

This commit is contained in:
Natasha Murashev
2015-12-29 16:54:20 +13:00
parent 4c4f0c8932
commit 2ff683bc0b

View File

@@ -57,6 +57,22 @@ dispatch_async(_backgroundQueue, ^{
});
```
In Swift:
```swift
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) {
let node = ASTextNode()
node.attributedString = NSAttributedString(string: "hello")
node.measure(CGSize(width: screenWidth, height: CGFloat.max))
node.frame = CGRect(origin: CGPointZero, size: node.calculatedSize)
// self.view isn't a node, so we can only use it on the main thread
dispatch_async(dispatch_get_main_queue()) {
self.view.addSubview(node.view)
}
}
```
AsyncDisplayKit at a glance:
* `ASImageNode` and `ASTextNode` are drop-in replacements for UIImageView and