Git Product home page Git Product logo

asyncdisplaykit's Introduction

AsyncDisplayKit

Build Status Version Platform License

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.

Quick start

ASDK is available on CocoaPods. Add the following to your Podfile:

pod 'AsyncDisplayKit'

(ASDK can also be used as a regular static library: Copy the project to your codebase manually, adding AsyncDisplayKit.xcodeproj to your workspace. Add libAsyncDisplayKit.a, AssetsLibrary, and Photos to the "Link Binary With Libraries" build phase. Include -lc++ -ObjC in your project linker flags.)

Import the framework header, or create an Objective-C bridging header if you're using Swift:

#import <AsyncDisplayKit/AsyncDisplayKit.h>

AsyncDisplayKit Nodes are a thread-safe abstraction layer over UIViews and CALayers:

node-view-layer diagram

You can construct entire node hierarchies in parallel, or instantiate and size a single node on a background thread — for example, you could do something like this in a UIViewController:

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_async(dispatch_get_main_queue(), ^{
    [self.view addSubview:node.view];
  });
});

AsyncDisplayKit at a glance:

  • ASImageNode and ASTextNode are drop-in replacements for UIImageView and UITextView.
  • ASMultiplexImageNode can load and display progressively higher-quality variants of an image over a slow cell network, letting you quickly show a low-resolution photo while the full size downloads.
  • ASNetworkImageNode is a simpler, single-image counterpart to the Multiplex node.
  • ASTableView and ASCollectionView are a node-aware UITableView and UICollectionView, respectively, that can asynchronously preload cell nodes — from loading network data to rendering — all without blocking the main thread.

You can also easily create your own nodes to implement node hierarchies or custom drawing.

Learn more

Testing

AsyncDisplayKit has extensive unit test coverage. You'll need to run pod install in the root AsyncDisplayKit directory to set up OCMock.

Contributing

See the CONTRIBUTING file for how to help out.

License

AsyncDisplayKit is BSD-licensed. We also provide an additional patent grant.

The files in the /examples directory are licensed under a separate license as specified in each file; documentation is licensed CC-BY-4.0.

asyncdisplaykit's People

Contributors

aleclarson avatar andyscott avatar appleguy avatar bdaz avatar davbeck avatar endocrimes avatar hanton avatar ianolito avatar ide avatar jamesgpearce avatar jercik avatar jpasqualini avatar l4u avatar lldong avatar lorixx avatar lxcid avatar mboyd1017 avatar mrh-is avatar nguyenhuy avatar nolanw avatar ocrickard avatar phatmann avatar rainypixels avatar raphaelmor avatar rcach avatar rnystrom avatar secretiverhyme avatar tanliboy avatar toulouse avatar yufenglv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.