Follow up for ASCollectionNode and ASTableNode background color fix

This commit is contained in:
Michael Schneider
2016-04-19 16:07:42 -07:00
parent 39da0987a3
commit 42174210c5
4 changed files with 11 additions and 17 deletions

View File

@@ -85,7 +85,7 @@ BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector)
// For classes like ASTableNode, ASCollectionNode, ASScrollNode and similar - we have to be sure to set certain properties // For classes like ASTableNode, ASCollectionNode, ASScrollNode and similar - we have to be sure to set certain properties
// like setFrame: and setBackgroundColor: directly to the UIView and not apply it to the layer only. // like setFrame: and setBackgroundColor: directly to the UIView and not apply it to the layer only.
BOOL ASDisplayNodeNeedsSpecialPropertiesSettingHandlingForFlags(ASDisplayNodeFlags flags) BOOL ASDisplayNodeNeedsSpecialPropertiesHandlingForFlags(ASDisplayNodeFlags flags)
{ {
return flags.synchronous && !flags.layerBacked; return flags.synchronous && !flags.layerBacked;
} }
@@ -961,7 +961,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
if (self.layerBacked) { if (self.layerBacked) {
[_pendingViewState applyToLayer:self.layer]; [_pendingViewState applyToLayer:self.layer];
} else { } else {
BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesSettingHandlingForFlags(_flags); BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesHandlingForFlags(_flags);
[_pendingViewState applyToView:self.view withSpecialPropertiesHandling:specialPropertiesHandling]; [_pendingViewState applyToView:self.view withSpecialPropertiesHandling:specialPropertiesHandling];
} }

View File

@@ -9,17 +9,10 @@
#import "_ASCoreAnimationExtras.h" #import "_ASCoreAnimationExtras.h"
#import "_ASPendingState.h" #import "_ASPendingState.h"
#import "ASInternalHelpers.h" #import "ASInternalHelpers.h"
#import "ASAssert.h"
#import "ASDisplayNodeInternal.h" #import "ASDisplayNodeInternal.h"
#import "ASDisplayNodeExtras.h"
#import "ASDisplayNode+Subclasses.h" #import "ASDisplayNode+Subclasses.h"
#import "ASDisplayNode+FrameworkPrivate.h" #import "ASDisplayNode+FrameworkPrivate.h"
#import "ASDisplayNode+Beta.h"
#import "ASEqualityHelpers.h"
#import "ASPendingStateController.h" #import "ASPendingStateController.h"
#import "ASThread.h"
#import "ASTextNode.h"
#import "ASTableNode.h"
/** /**
* The following macros are conveniences to help in the common tasks related to the bridging that ASDisplayNode does to UIView and CALayer. * The following macros are conveniences to help in the common tasks related to the bridging that ASDisplayNode does to UIView and CALayer.
@@ -240,7 +233,7 @@ if (shouldApply) { _layer.layerProperty = (layerValueExpr); } else { ASDisplayNo
// For classes like ASTableNode, ASCollectionNode, ASScrollNode and similar - make sure UIView gets setFrame: // For classes like ASTableNode, ASCollectionNode, ASScrollNode and similar - make sure UIView gets setFrame:
struct ASDisplayNodeFlags flags = _flags; struct ASDisplayNodeFlags flags = _flags;
BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesSettingHandlingForFlags(flags); BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesHandlingForFlags(flags);
BOOL nodeLoaded = __loaded(self); BOOL nodeLoaded = __loaded(self);
BOOL isMainThread = ASDisplayNodeThreadIsMain(); BOOL isMainThread = ASDisplayNodeThreadIsMain();
@@ -583,11 +576,12 @@ if (shouldApply) { _layer.layerProperty = (layerValueExpr); } else { ASDisplayNo
if (shouldApply) { if (shouldApply) {
CGColorRef oldBackgroundCGColor = _layer.backgroundColor; CGColorRef oldBackgroundCGColor = _layer.backgroundColor;
_layer.backgroundColor = newBackgroundCGColor;
BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesSettingHandlingForFlags(_flags); BOOL specialPropertiesHandling = ASDisplayNodeNeedsSpecialPropertiesHandlingForFlags(_flags);
if (specialPropertiesHandling) { if (specialPropertiesHandling) {
_view.backgroundColor = newBackgroundColor; _view.backgroundColor = newBackgroundColor;
} else {
_layer.backgroundColor = newBackgroundCGColor;
} }
if (!CGColorEqualToColor(oldBackgroundCGColor, newBackgroundCGColor)) { if (!CGColorEqualToColor(oldBackgroundCGColor, newBackgroundCGColor)) {

View File

@@ -28,7 +28,7 @@
struct ASDisplayNodeFlags; struct ASDisplayNodeFlags;
BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector); BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector);
BOOL ASDisplayNodeNeedsSpecialPropertiesSettingHandlingForFlags(ASDisplayNodeFlags flags); BOOL ASDisplayNodeNeedsSpecialPropertiesHandlingForFlags(ASDisplayNodeFlags flags);
/// Get the pending view state for the node, creating one if needed. /// Get the pending view state for the node, creating one if needed.
_ASPendingState *ASDisplayNodeGetPendingState(ASDisplayNode *node); _ASPendingState *ASDisplayNodeGetPendingState(ASDisplayNode *node);

View File

@@ -790,12 +790,12 @@ static UIColor *defaultTintColor = nil;
view.clipsToBounds = clipsToBounds; view.clipsToBounds = clipsToBounds;
if (flags.setBackgroundColor) { if (flags.setBackgroundColor) {
// Set the background color to the layer as in the UIView bridge we use this value as background color // We have to make sure certain nodes get the background color call directly set
layer.backgroundColor = backgroundColor;
// We have to make sure certain nodes get the background color call directly
if (specialPropertiesHandling) { if (specialPropertiesHandling) {
view.backgroundColor = [UIColor colorWithCGColor:backgroundColor]; view.backgroundColor = [UIColor colorWithCGColor:backgroundColor];
} else {
// Set the background color to the layer as in the UIView bridge we use this value as background color
layer.backgroundColor = backgroundColor;
} }
} }