From 389945d69d4f8e3f18557322e28fa82338ca8e05 Mon Sep 17 00:00:00 2001 From: Rajinder Ramgarhia Date: Wed, 20 Jan 2016 14:29:34 -0500 Subject: [PATCH] ASButtonNode sets its subnodes as layer backed, but itelf should not be layer backed --- AsyncDisplayKit/ASButtonNode.h | 4 ++-- AsyncDisplayKit/ASButtonNode.mm | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/AsyncDisplayKit/ASButtonNode.h b/AsyncDisplayKit/ASButtonNode.h index 5ce7d966cc..305121b3a6 100644 --- a/AsyncDisplayKit/ASButtonNode.h +++ b/AsyncDisplayKit/ASButtonNode.h @@ -47,7 +47,7 @@ - (NSAttributedString * _Nullable)attributedTitleForState:(ASControlState)state; /** - * Sets the styled title to use for the specified state. + * Sets the styled title to use for the specified state. This will reset styled title previously set with -setTitle:withFont:withColor:forState. * * @param title The styled text string to use for the title. * @param state The state that uses the specified title. The possible values are described in ASControlState. @@ -55,7 +55,7 @@ - (void)setAttributedTitle:(nullable NSAttributedString *)title forState:(ASControlState)state; /** - * Sets the title to use for the specified state. + * Sets the title to use for the specified state. This will reset styled title previously set with -setAttributedTitle:forState. * * @param title The styled text string to use for the title. * @param font The font to use for the title. diff --git a/AsyncDisplayKit/ASButtonNode.mm b/AsyncDisplayKit/ASButtonNode.mm index 0dc3812f7a..c0abfe11ca 100644 --- a/AsyncDisplayKit/ASButtonNode.mm +++ b/AsyncDisplayKit/ASButtonNode.mm @@ -48,7 +48,12 @@ _titleNode = [[ASTextNode alloc] init]; _imageNode = [[ASImageNode alloc] init]; _backgroundImageNode = [[ASImageNode alloc] init]; + [_backgroundImageNode setContentMode:UIViewContentModeScaleToFill]; + [_titleNode setLayerBacked:YES]; + [_imageNode setLayerBacked:YES]; + [_backgroundImageNode setLayerBacked:YES]; + _contentHorizontalAlignment = ASAlignmentMiddle; _contentVerticalAlignment = ASAlignmentCenter; @@ -59,6 +64,12 @@ return self; } +- (void)setLayerBacked:(BOOL)layerBacked +{ + ASDisplayNodeAssert(!layerBacked, @"ASButtonNode must not be layer backed!"); + [super setLayerBacked:layerBacked]; +} + - (void)setEnabled:(BOOL)enabled { [super setEnabled:enabled];