Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 389945d

Browse files
author
Rajinder Ramgarhia
committed
ASButtonNode sets its subnodes as layer backed, but itelf should not be layer backed
1 parent 6c56a60 commit 389945d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

AsyncDisplayKit/ASButtonNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
- (NSAttributedString * _Nullable)attributedTitleForState:(ASControlState)state;
4848

4949
/**
50-
* Sets the styled title to use for the specified state.
50+
* Sets the styled title to use for the specified state. This will reset styled title previously set with -setTitle:withFont:withColor:forState.
5151
*
5252
* @param title The styled text string to use for the title.
5353
* @param state The state that uses the specified title. The possible values are described in ASControlState.
5454
*/
5555
- (void)setAttributedTitle:(nullable NSAttributedString *)title forState:(ASControlState)state;
5656

5757
/**
58-
* Sets the title to use for the specified state.
58+
* Sets the title to use for the specified state. This will reset styled title previously set with -setAttributedTitle:forState.
5959
*
6060
* @param title The styled text string to use for the title.
6161
* @param font The font to use for the title.

AsyncDisplayKit/ASButtonNode.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ - (instancetype)init
4848
_titleNode = [[ASTextNode alloc] init];
4949
_imageNode = [[ASImageNode alloc] init];
5050
_backgroundImageNode = [[ASImageNode alloc] init];
51+
[_backgroundImageNode setContentMode:UIViewContentModeScaleToFill];
5152

53+
[_titleNode setLayerBacked:YES];
54+
[_imageNode setLayerBacked:YES];
55+
[_backgroundImageNode setLayerBacked:YES];
56+
5257
_contentHorizontalAlignment = ASAlignmentMiddle;
5358
_contentVerticalAlignment = ASAlignmentCenter;
5459

@@ -59,6 +64,12 @@ - (instancetype)init
5964
return self;
6065
}
6166

67+
- (void)setLayerBacked:(BOOL)layerBacked
68+
{
69+
ASDisplayNodeAssert(!layerBacked, @"ASButtonNode must not be layer backed!");
70+
[super setLayerBacked:layerBacked];
71+
}
72+
6273
- (void)setEnabled:(BOOL)enabled
6374
{
6475
[super setEnabled:enabled];

0 commit comments

Comments
 (0)