mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-05-12 08:05:36 +08:00
Added Swift example to README
This commit is contained in:
16
README.md
16
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user