Smooth asynchronous user interfaces for iOS apps — AsyncDisplayKit

Facebook have open-sourced another bit of impressive code.

 

AsyncDisplayKit is an iOS framework that keeps even the most complex user interfaces smooth and responsive. It was originally built to make Facebook's Paper possible, and goes hand-in-hand with pop's physics-based animations — but it's just as powerful with UIKit Dynamics and conventional app designs.

Also available on CocoaPods, you create Nodes with replacements for regular UIView objects, such as UIImageView and UITextView, you ensure you don't block the main tread and pre-load cell nodes optimally.

 

dispatch_async(_backgroundQueue, ^{
  ASTextNode *node = [[ASTextNode alloc] init];
  node.attributedString = [[NSAttributedString alloc] initWithString:@"hello!"
                                                          attributes:nil];
  [node measure:CGSizeMake(screenWidth, FLT_MAX)];
  node.frame = (CGRect){ CGPointZero, node.calculatedSize };

  // self.view isn't a node, so we can only use it on the main thread
  dispatch_sync(dispatch_get_main_queue(), ^{
    [self.view addSubview:node.view];
  });
});

 

For more information, visit the official technical page at: Smooth asynchronous user interfaces for iOS apps — AsyncDisplayKit.