I looked into the internals of UIImageView a bit. I would recommend to not fixing this in a universal way. UIImageView is specifically optimized for performance and does not use the usual way to provide the contents of the CALayer that backs the UIImageView. Furthermore we cannot trigger a recreation of the contents of the UIImageView layer as if it get’s cleared and we call setNeedsDisplay on it it goes trough the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately UIImageView does not do it, it actually does not implement some of the methods at all, so nothing will show up. It’s getting better, by calling setNeedsDisplay on an UIImageView layer it actually clears the contents and nothing is visible anymore. So we have to be careful to not calling that too. Unfortunately I didn’t find a way yet to trigger a recreation of the UIImageView layers content except calling the private _updateState method. That said it’s different for layers of other UIKit components like UILabel for example. Clearing the contents of a UILabel layer and calling setNeedsDisplay on the layer usually recreates the contents of the it and it will show up again. This commit prevents to clear the contents of a layer for all wrapped UIKit and instead only NOT clear the content if the node wraps a UIImageView otherwise we should clear the contents of the layer to reclaim memory as usual.
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, MapKit, 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:
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];
});
});
In 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:
ASImageNodeandASTextNodeare drop-in replacements for UIImageView and UITextView.ASMultiplexImageNodecan 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.ASNetworkImageNodeis a simpler, single-image counterpart to the Multiplex node.ASTableViewandASCollectionVieware 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
- Read the Getting Started guide
- Get the sample projects
- Browse the API reference
- Watch the NSLondon talk or the NSSpain talk
Getting Help
We use Slack for real-time debugging, community updates, and general talk about ASDK. Signup at http://asdk-slack-auto-invite.herokuapp.com or email AsyncDisplayKit(at)gmail.com to get an invite.
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.

