[ASTextNode] Actually deprecate attributedString property (#2151)

This commit is contained in:
Adlai Holler
2016-09-01 16:43:03 -07:00
committed by GitHub
parent f8e135a1be
commit 5e3627a9cd
31 changed files with 65 additions and 65 deletions

View File

@@ -183,8 +183,8 @@
newTitle = _normalAttributedTitle; newTitle = _normalAttributedTitle;
} }
if ((_titleNode != nil || newTitle.length > 0) && [self.titleNode.attributedString isEqualToAttributedString:newTitle] == NO) { if ((_titleNode != nil || newTitle.length > 0) && [self.titleNode.attributedText isEqualToAttributedString:newTitle] == NO) {
_titleNode.attributedString = newTitle; _titleNode.attributedText = newTitle;
self.accessibilityLabel = _titleNode.accessibilityLabel; self.accessibilityLabel = _titleNode.accessibilityLabel;
[self setNeedsLayout]; [self setNeedsLayout];
} }
@@ -479,7 +479,7 @@
[children addObject:_imageNode]; [children addObject:_imageNode];
} }
if (_titleNode.attributedString.length > 0) { if (_titleNode.attributedText.length > 0) {
[children addObject:_titleNode]; [children addObject:_titleNode];
} }
@@ -508,7 +508,7 @@
[super layout]; [super layout];
_backgroundImageNode.hidden = (_backgroundImageNode.image == nil); _backgroundImageNode.hidden = (_backgroundImageNode.image == nil);
_imageNode.hidden = (_imageNode.image == nil); _imageNode.hidden = (_imageNode.image == nil);
_titleNode.hidden = (_titleNode.attributedString.length == 0); _titleNode.hidden = (_titleNode.attributedText.length == 0);
} }
@end @end

View File

@@ -297,7 +297,7 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
- (instancetype)init - (instancetype)init
{ {
return [self initWithAttributes:[self defaultTextAttributes] insets:[self defaultTextInsets]]; return [self initWithAttributes:[ASTextCellNode defaultTextAttributes] insets:[ASTextCellNode defaultTextInsets]];
} }
- (instancetype)initWithAttributes:(NSDictionary *)textAttributes insets:(UIEdgeInsets)textInsets - (instancetype)initWithAttributes:(NSDictionary *)textAttributes insets:(UIEdgeInsets)textInsets
@@ -306,8 +306,8 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
if (self) { if (self) {
_textInsets = textInsets; _textInsets = textInsets;
_textAttributes = [textAttributes copy]; _textAttributes = [textAttributes copy];
self.automaticallyManagesSubnodes = YES;
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
[self addSubnode:_textNode];
} }
return self; return self;
} }
@@ -317,12 +317,12 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:self.textInsets child:self.textNode]; return [ASInsetLayoutSpec insetLayoutSpecWithInsets:self.textInsets child:self.textNode];
} }
- (NSDictionary *)defaultTextAttributes + (NSDictionary *)defaultTextAttributes
{ {
return @{NSFontAttributeName : [UIFont systemFontOfSize:kASTextCellNodeDefaultFontSize]}; return @{NSFontAttributeName : [UIFont systemFontOfSize:kASTextCellNodeDefaultFontSize]};
} }
- (UIEdgeInsets)defaultTextInsets + (UIEdgeInsets)defaultTextInsets
{ {
return UIEdgeInsetsMake(kASTextCellNodeDefaultVerticalPadding, kASTextCellNodeDefaultHorizontalPadding, kASTextCellNodeDefaultVerticalPadding, kASTextCellNodeDefaultHorizontalPadding); return UIEdgeInsetsMake(kASTextCellNodeDefaultVerticalPadding, kASTextCellNodeDefaultHorizontalPadding, kASTextCellNodeDefaultVerticalPadding, kASTextCellNodeDefaultHorizontalPadding);
} }
@@ -333,14 +333,14 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
_textAttributes = [textAttributes copy]; _textAttributes = [textAttributes copy];
[self updateAttributedString]; [self updateAttributedText];
} }
- (void)setTextInsets:(UIEdgeInsets)textInsets - (void)setTextInsets:(UIEdgeInsets)textInsets
{ {
_textInsets = textInsets; _textInsets = textInsets;
[self updateAttributedString]; [self setNeedsLayout];
} }
- (void)setText:(NSString *)text - (void)setText:(NSString *)text
@@ -349,17 +349,17 @@ static const CGFloat kASTextCellNodeDefaultVerticalPadding = 11.0f;
_text = [text copy]; _text = [text copy];
[self updateAttributedString]; [self updateAttributedText];
} }
- (void)updateAttributedString - (void)updateAttributedText
{ {
if (_text == nil) { if (_text == nil) {
_textNode.attributedString = nil; _textNode.attributedText = nil;
return; return;
} }
_textNode.attributedString = [[NSAttributedString alloc] initWithString:self.text attributes:self.textAttributes]; _textNode.attributedText = [[NSAttributedString alloc] initWithString:self.text attributes:self.textAttributes];
[self setNeedsLayout]; [self setNeedsLayout];
} }

View File

@@ -326,12 +326,12 @@ struct ASImageNodeDrawParameters {
CGFloat pixelCountRatio = (imageSizeInPixels.width * imageSizeInPixels.height) / (boundsSizeInPixels.width * boundsSizeInPixels.height); CGFloat pixelCountRatio = (imageSizeInPixels.width * imageSizeInPixels.height) / (boundsSizeInPixels.width * boundsSizeInPixels.height);
if (pixelCountRatio != 1.0) { if (pixelCountRatio != 1.0) {
NSString *scaleString = [NSString stringWithFormat:@"%.2fx", pixelCountRatio]; NSString *scaleString = [NSString stringWithFormat:@"%.2fx", pixelCountRatio];
_debugLabelNode.attributedString = [[NSAttributedString alloc] initWithString:scaleString attributes:[self debugLabelAttributes]]; _debugLabelNode.attributedText = [[NSAttributedString alloc] initWithString:scaleString attributes:[self debugLabelAttributes]];
_debugLabelNode.hidden = NO; _debugLabelNode.hidden = NO;
[self setNeedsLayout]; [self setNeedsLayout];
} else { } else {
_debugLabelNode.hidden = YES; _debugLabelNode.hidden = YES;
_debugLabelNode.attributedString = nil; _debugLabelNode.attributedText = nil;
} }
} }

View File

@@ -291,16 +291,16 @@ typedef NS_ENUM(NSUInteger, ASTextNodeHighlightStyle) {
@see attributedText @see attributedText
*/ */
@property (nullable, nonatomic, copy) NSAttributedString *attributedString; @property (nullable, nonatomic, copy) NSAttributedString *attributedString ASDISPLAYNODE_DEPRECATED;
/** /**
The truncationAttributedString and truncationAttributedText properties are equivalent, but attributedText is now the The truncationAttributedString and truncationAttributedText properties are equivalent, but truncationAttributedText is now the
standard API name in order to match UILabel and ASEditableTextNode. standard API name in order to match UILabel and ASEditableTextNode.
@see truncationAttributedText @see truncationAttributedText
*/ */
@property (nullable, nonatomic, copy) NSAttributedString *truncationAttributedString; @property (nullable, nonatomic, copy) NSAttributedString *truncationAttributedString ASDISPLAYNODE_DEPRECATED;
@end @end

View File

@@ -346,7 +346,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
{ {
if (_elapsedTextNode == nil) { if (_elapsedTextNode == nil) {
_elapsedTextNode = [[ASTextNode alloc] init]; _elapsedTextNode = [[ASTextNode alloc] init];
_elapsedTextNode.attributedString = [self timeLabelAttributedStringForString:@"00:00" _elapsedTextNode.attributedText = [self timeLabelAttributedStringForString:@"00:00"
forControlType:ASVideoPlayerNodeControlTypeElapsedText]; forControlType:ASVideoPlayerNodeControlTypeElapsedText];
_elapsedTextNode.truncationMode = NSLineBreakByClipping; _elapsedTextNode.truncationMode = NSLineBreakByClipping;
@@ -359,7 +359,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
{ {
if (_durationTextNode == nil) { if (_durationTextNode == nil) {
_durationTextNode = [[ASTextNode alloc] init]; _durationTextNode = [[ASTextNode alloc] init];
_durationTextNode.attributedString = [self timeLabelAttributedStringForString:@"00:00" _durationTextNode.attributedText = [self timeLabelAttributedStringForString:@"00:00"
forControlType:ASVideoPlayerNodeControlTypeDurationText]; forControlType:ASVideoPlayerNodeControlTypeDurationText];
_durationTextNode.truncationMode = NSLineBreakByClipping; _durationTextNode.truncationMode = NSLineBreakByClipping;
@@ -428,7 +428,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
return; return;
} }
NSString *formattedDuration = [self timeStringForCMTime:_duration forTimeLabelType:ASVideoPlayerNodeControlTypeDurationText]; NSString *formattedDuration = [self timeStringForCMTime:_duration forTimeLabelType:ASVideoPlayerNodeControlTypeDurationText];
_durationTextNode.attributedString = [self timeLabelAttributedStringForString:formattedDuration forControlType:ASVideoPlayerNodeControlTypeDurationText]; _durationTextNode.attributedText = [self timeLabelAttributedStringForString:formattedDuration forControlType:ASVideoPlayerNodeControlTypeDurationText];
} }
- (void)updateElapsedTimeLabel:(NSTimeInterval)seconds - (void)updateElapsedTimeLabel:(NSTimeInterval)seconds
@@ -436,8 +436,8 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
if (!_elapsedTextNode) { if (!_elapsedTextNode) {
return; return;
} }
NSString *formatteElapsed = [self timeStringForCMTime:CMTimeMakeWithSeconds( seconds, _videoNode.periodicTimeObserverTimescale ) forTimeLabelType:ASVideoPlayerNodeControlTypeElapsedText]; NSString *formattedElapsed = [self timeStringForCMTime:CMTimeMakeWithSeconds( seconds, _videoNode.periodicTimeObserverTimescale ) forTimeLabelType:ASVideoPlayerNodeControlTypeElapsedText];
_elapsedTextNode.attributedString = [self timeLabelAttributedStringForString:formatteElapsed forControlType:ASVideoPlayerNodeControlTypeElapsedText]; _elapsedTextNode.attributedText = [self timeLabelAttributedStringForString:formattedElapsed forControlType:ASVideoPlayerNodeControlTypeElapsedText];
} }
- (NSAttributedString*)timeLabelAttributedStringForString:(NSString*)string forControlType:(ASVideoPlayerNodeControlType)controlType - (NSAttributedString*)timeLabelAttributedStringForString:(NSString*)string forControlType:(ASVideoPlayerNodeControlType)controlType

View File

@@ -704,7 +704,7 @@ static BOOL __shouldShowRangeDebugOverlay = NO;
_debugString = [[_rangeController dataSource] nameForRangeControllerDataSource]; _debugString = [[_rangeController dataSource] nameForRangeControllerDataSource];
} }
if (_debugString) { if (_debugString) {
_debugText.attributedString = [_ASRangeDebugBarView whiteAttributedStringFromString:_debugString withSize:size]; _debugText.attributedText = [_ASRangeDebugBarView whiteAttributedStringFromString:_debugString withSize:size];
} }
if (ASScrollDirectionContainsVerticalDirection(_scrollDirection)) { if (ASScrollDirectionContainsVerticalDirection(_scrollDirection)) {

View File

@@ -34,7 +34,7 @@ static CGFloat kInsets = 15.0;
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:text _textNode.attributedText = [[NSAttributedString alloc] initWithString:text
attributes:[self textAttributes]]; attributes:[self textAttributes]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];
} }

View File

@@ -70,7 +70,7 @@
_photoImageView.layerBacked = YES; _photoImageView.layerBacked = YES;
_userNameLabel = [[ASTextNode alloc] init]; _userNameLabel = [[ASTextNode alloc] init];
_userNameLabel.attributedString = [photo.ownerUserProfile usernameAttributedStringWithFontSize:FONT_SIZE]; _userNameLabel.attributedText = [photo.ownerUserProfile usernameAttributedStringWithFontSize:FONT_SIZE];
_photoLocationLabel = [[ASTextNode alloc] init]; _photoLocationLabel = [[ASTextNode alloc] init];
_photoLocationLabel.maximumNumberOfLines = 1; _photoLocationLabel.maximumNumberOfLines = 1;
@@ -80,7 +80,7 @@
// make sure to use _photoModel instance variable as photo may change when cell is reused, // make sure to use _photoModel instance variable as photo may change when cell is reused,
// where as local variable will never change // where as local variable will never change
if (locationModel == _photoModel.location) { if (locationModel == _photoModel.location) {
_photoLocationLabel.attributedString = [photo locationAttributedStringWithFontSize:FONT_SIZE]; _photoLocationLabel.attributedText = [photo locationAttributedStringWithFontSize:FONT_SIZE];
[self setNeedsLayout]; [self setNeedsLayout];
} }
}]; }];
@@ -181,7 +181,7 @@
{ {
ASTextNode *textNode = [[ASTextNode alloc] init]; ASTextNode *textNode = [[ASTextNode alloc] init];
textNode.layerBacked = YES; textNode.layerBacked = YES;
textNode.attributedString = attributedString; textNode.attributedText = attributedString;
return textNode; return textNode;
} }

View File

@@ -79,7 +79,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{ {
BOOL hasDescription = self.descriptionNode.attributedString.length > 0; BOOL hasDescription = self.descriptionNode.attributedText.length > 0;
ASStackLayoutSpec *verticalStackLayoutSpec = [ASStackLayoutSpec verticalStackLayoutSpec]; ASStackLayoutSpec *verticalStackLayoutSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
verticalStackLayoutSpec.spacing = 5.0; verticalStackLayoutSpec.spacing = 5.0;
@@ -184,7 +184,7 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
#pragma mark ASTextNode #pragma mark ASTextNode
ASTextNode *textNode = [ASTextNode new]; ASTextNode *textNode = [ASTextNode new];
textNode.attributedString = [[NSAttributedString alloc] initWithString:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum varius nisi quis mattis dignissim. Proin convallis odio nec ipsum molestie, in porta quam viverra. Fusce ornare dapibus velit, nec malesuada mauris pretium vitae. Etiam malesuada ligula magna."]; textNode.attributedText = [[NSAttributedString alloc] initWithString:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum varius nisi quis mattis dignissim. Proin convallis odio nec ipsum molestie, in porta quam viverra. Fusce ornare dapibus velit, nec malesuada mauris pretium vitae. Etiam malesuada ligula magna."];
parentNode = [self centeringParentNodeWithChild:textNode]; parentNode = [self centeringParentNodeWithChild:textNode];
parentNode.entryTitle = @"ASTextNode"; parentNode.entryTitle = @"ASTextNode";
@@ -529,11 +529,11 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
NSFontAttributeName : [UIFont boldSystemFontOfSize:14.0], NSFontAttributeName : [UIFont boldSystemFontOfSize:14.0],
NSForegroundColorAttributeName : [UIColor blackColor] NSForegroundColorAttributeName : [UIColor blackColor]
}; };
cellNode.titleNode.attributedString = [[NSAttributedString alloc] initWithString:node.entryTitle attributes:titleNodeAttributes]; cellNode.titleNode.attributedText = [[NSAttributedString alloc] initWithString:node.entryTitle attributes:titleNodeAttributes];
if (node.entryDescription) { if (node.entryDescription) {
NSDictionary *descriptionNodeAttributes = @{NSForegroundColorAttributeName : [UIColor lightGrayColor]}; NSDictionary *descriptionNodeAttributes = @{NSForegroundColorAttributeName : [UIColor lightGrayColor]};
cellNode.descriptionNode.attributedString = [[NSAttributedString alloc] initWithString:node.entryDescription attributes:descriptionNodeAttributes]; cellNode.descriptionNode.attributedText = [[NSAttributedString alloc] initWithString:node.entryDescription attributes:descriptionNodeAttributes];
} }
return cellNode; return cellNode;

View File

@@ -72,7 +72,7 @@ static CGFloat kTextPadding = 10.0f;
NSForegroundColorAttributeName: [UIColor blueColor], NSForegroundColorAttributeName: [UIColor blueColor],
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot), NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot),
} range:[blurb rangeOfString:@"catipsum.com"]]; } range:[blurb rangeOfString:@"catipsum.com"]];
_textNode.attributedString = string; _textNode.attributedText = string;
// add it as a subnode, and we're done // add it as a subnode, and we're done
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -152,33 +152,33 @@ const CGFloat kSoldOutGBHeight = 50.0;
- (void)updateLabels { - (void)updateLabels {
// Set Title text // Set Title text
if (self.viewModel.titleText) { if (self.viewModel.titleText) {
self.titleLabel.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.titleText attributes:[ItemStyles titleStyle]]; self.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.titleText attributes:[ItemStyles titleStyle]];
} }
if (self.viewModel.firstInfoText) { if (self.viewModel.firstInfoText) {
self.firstInfoLabel.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.firstInfoText attributes:[ItemStyles subtitleStyle]]; self.firstInfoLabel.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.firstInfoText attributes:[ItemStyles subtitleStyle]];
} }
if (self.viewModel.secondInfoText) { if (self.viewModel.secondInfoText) {
self.secondInfoLabel.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.secondInfoText attributes:[ItemStyles secondInfoStyle]]; self.secondInfoLabel.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.secondInfoText attributes:[ItemStyles secondInfoStyle]];
} }
if (self.viewModel.originalPriceText) { if (self.viewModel.originalPriceText) {
self.originalPriceLabel.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.originalPriceText attributes:[ItemStyles originalPriceStyle]]; self.originalPriceLabel.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.originalPriceText attributes:[ItemStyles originalPriceStyle]];
} }
if (self.viewModel.finalPriceText) { if (self.viewModel.finalPriceText) {
self.finalPriceLabel.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.finalPriceText attributes:[ItemStyles finalPriceStyle]]; self.finalPriceLabel.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.finalPriceText attributes:[ItemStyles finalPriceStyle]];
} }
if (self.viewModel.distanceLabelText) { if (self.viewModel.distanceLabelText) {
NSString *format = [ItemNode isRTL] ? @"%@ •" : @"• %@"; NSString *format = [ItemNode isRTL] ? @"%@ •" : @"• %@";
NSString *distanceText = [NSString stringWithFormat:format, self.viewModel.distanceLabelText]; NSString *distanceText = [NSString stringWithFormat:format, self.viewModel.distanceLabelText];
self.distanceLabel.attributedString = [[NSAttributedString alloc] initWithString:distanceText attributes:[ItemStyles distanceStyle]]; self.distanceLabel.attributedText = [[NSAttributedString alloc] initWithString:distanceText attributes:[ItemStyles distanceStyle]];
} }
BOOL isSoldOut = self.viewModel.soldOutText != nil; BOOL isSoldOut = self.viewModel.soldOutText != nil;
if (isSoldOut) { if (isSoldOut) {
NSString *soldOutText = self.viewModel.soldOutText; NSString *soldOutText = self.viewModel.soldOutText;
self.soldOutLabelFlat.attributedString = [[NSAttributedString alloc] initWithString:soldOutText attributes:[ItemStyles soldOutStyle]]; self.soldOutLabelFlat.attributedText = [[NSAttributedString alloc] initWithString:soldOutText attributes:[ItemStyles soldOutStyle]];
} }
self.soldOutOverlay.hidden = !isSoldOut; self.soldOutOverlay.hidden = !isSoldOut;
self.soldOutLabelFlat.hidden = !isSoldOut; self.soldOutLabelFlat.hidden = !isSoldOut;
@@ -186,7 +186,7 @@ const CGFloat kSoldOutGBHeight = 50.0;
BOOL hasBadge = self.viewModel.badgeText != nil; BOOL hasBadge = self.viewModel.badgeText != nil;
if (hasBadge) { if (hasBadge) {
self.badge.attributedString = [[NSAttributedString alloc] initWithString:self.viewModel.badgeText attributes:[ItemStyles badgeStyle]]; self.badge.attributedText = [[NSAttributedString alloc] initWithString:self.viewModel.badgeText attributes:[ItemStyles badgeStyle]];
self.badge.backgroundColor = [ItemStyles badgeColor]; self.badge.backgroundColor = [ItemStyles badgeColor];
} }
self.badge.hidden = !hasBadge; self.badge.hidden = !hasBadge;

View File

@@ -63,7 +63,7 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot), NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot),
} }
range:[blurb rangeOfString:@"placekitten.com"]]; range:[blurb rangeOfString:@"placekitten.com"]];
_textNode.attributedString = string; _textNode.attributedText = string;
// add it as a subnode, and we're done // add it as a subnode, and we're done
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -98,7 +98,7 @@ static const CGFloat kInnerPadding = 10.0f;
// lorem ipsum text, plus some nice styling // lorem ipsum text, plus some nice styling
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:[self kittyIpsum] _textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
attributes:[self textStyle]]; attributes:[self textStyle]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -38,7 +38,7 @@
_countNode = [[ASTextNode alloc] init]; _countNode = [[ASTextNode alloc] init];
if (_commentsCount > 0) { if (_commentsCount > 0) {
_countNode.attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%zd", _commentsCount] attributes:[TextStyles cellControlStyle]]; _countNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%zd", _commentsCount] attributes:[TextStyles cellControlStyle]];
} }
[self addSubnode:_countNode]; [self addSubnode:_countNode];

View File

@@ -42,7 +42,7 @@
if (_likesCount > 0) { if (_likesCount > 0) {
NSDictionary *attributes = _liked ? [TextStyles cellControlColoredStyle] : [TextStyles cellControlStyle]; NSDictionary *attributes = _liked ? [TextStyles cellControlColoredStyle] : [TextStyles cellControlStyle];
_countNode.attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld", (long)_likesCount] attributes:attributes]; _countNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld", (long)_likesCount] attributes:attributes];
} }
[self addSubnode:_countNode]; [self addSubnode:_countNode];

View File

@@ -52,13 +52,13 @@
// Name node // Name node
_nameNode = [[ASTextNode alloc] init]; _nameNode = [[ASTextNode alloc] init];
_nameNode.attributedString = [[NSAttributedString alloc] initWithString:_post.name attributes:[TextStyles nameStyle]]; _nameNode.attributedText = [[NSAttributedString alloc] initWithString:_post.name attributes:[TextStyles nameStyle]];
_nameNode.maximumNumberOfLines = 1; _nameNode.maximumNumberOfLines = 1;
[self addSubnode:_nameNode]; [self addSubnode:_nameNode];
// Username node // Username node
_usernameNode = [[ASTextNode alloc] init]; _usernameNode = [[ASTextNode alloc] init];
_usernameNode.attributedString = [[NSAttributedString alloc] initWithString:_post.username attributes:[TextStyles usernameStyle]]; _usernameNode.attributedText = [[NSAttributedString alloc] initWithString:_post.username attributes:[TextStyles usernameStyle]];
_usernameNode.flexShrink = YES; //if name and username don't fit to cell width, allow username shrink _usernameNode.flexShrink = YES; //if name and username don't fit to cell width, allow username shrink
_usernameNode.truncationMode = NSLineBreakByTruncatingTail; _usernameNode.truncationMode = NSLineBreakByTruncatingTail;
_usernameNode.maximumNumberOfLines = 1; _usernameNode.maximumNumberOfLines = 1;
@@ -66,7 +66,7 @@
// Time node // Time node
_timeNode = [[ASTextNode alloc] init]; _timeNode = [[ASTextNode alloc] init];
_timeNode.attributedString = [[NSAttributedString alloc] initWithString:_post.time attributes:[TextStyles timeStyle]]; _timeNode.attributedText = [[NSAttributedString alloc] initWithString:_post.time attributes:[TextStyles timeStyle]];
[self addSubnode:_timeNode]; [self addSubnode:_timeNode];
// Post node // Post node
@@ -98,7 +98,7 @@
_postNode.delegate = self; _postNode.delegate = self;
_postNode.userInteractionEnabled = YES; _postNode.userInteractionEnabled = YES;
_postNode.linkAttributeNames = @[ kLinkAttributeName ]; _postNode.linkAttributeNames = @[ kLinkAttributeName ];
_postNode.attributedString = attrString; _postNode.attributedText = attrString;
_postNode.passthroughNonlinkTouches = YES; // passes touches through when they aren't on a link _postNode.passthroughNonlinkTouches = YES; // passes touches through when they aren't on a link
} }

View File

@@ -27,7 +27,7 @@ final class TailLoadingCellNode: ASCellNode {
override init() { override init() {
super.init() super.init()
addSubnode(text) addSubnode(text)
text.attributedString = NSAttributedString( text.attributedText = NSAttributedString(
string: "Loading…", string: "Loading…",
attributes: [ attributes: [
NSFontAttributeName: UIFont.systemFontOfSize(12), NSFontAttributeName: UIFont.systemFontOfSize(12),

View File

@@ -68,7 +68,7 @@
- (void)setIndexPath:(NSIndexPath *)indexPath - (void)setIndexPath:(NSIndexPath *)indexPath
{ {
_indexPath = indexPath; _indexPath = indexPath;
_indexPathTextNode.attributedString = [[NSAttributedString alloc] initWithString:[indexPath description] attributes:nil]; _indexPathTextNode.attributedText = [[NSAttributedString alloc] initWithString:[indexPath description] attributes:nil];
} }
//- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize //- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize

View File

@@ -89,7 +89,7 @@ static const CGFloat kInnerPadding = 10.0f;
// lorem ipsum text, plus some nice styling // lorem ipsum text, plus some nice styling
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:[self kittyIpsum] _textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
attributes:[self textStyle]]; attributes:[self textStyle]];
_textNode.flexShrink = YES; _textNode.flexShrink = YES;
_textNode.flexGrow = YES; _textNode.flexGrow = YES;

View File

@@ -66,7 +66,7 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
} }
range:[blurb rangeOfString:@"placekitten.com"]]; range:[blurb rangeOfString:@"placekitten.com"]];
_textNode.attributedString = string; _textNode.attributedText = string;
ASStackLayoutSpec *stackSpec = [ASStackLayoutSpec verticalStackLayoutSpec]; ASStackLayoutSpec *stackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
stackSpec.children = @[_textNode, _buttonNode]; stackSpec.children = @[_textNode, _buttonNode];

View File

@@ -34,7 +34,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ASTextNode *node = [[ASTextNode alloc] init]; ASTextNode *node = [[ASTextNode alloc] init];
node.attributedString = [[NSAttributedString alloc] initWithString:@"hello world"]; node.attributedText = [[NSAttributedString alloc] initWithString:@"hello world"];
[node measure:(CGSize){.width = screenSize.width, .height = CGFLOAT_MAX}]; [node measure:(CGSize){.width = screenSize.width, .height = CGFLOAT_MAX}];
node.frame = (CGRect) {.origin = (CGPoint){.x = 100, .y = 100}, .size = node.calculatedSize }; node.frame = (CGRect) {.origin = (CGPoint){.x = 100, .y = 100}, .size = node.calculatedSize };

View File

@@ -30,7 +30,7 @@
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:text _textNode.attributedText = [[NSAttributedString alloc] initWithString:text
attributes:[self textAttributes]]; attributes:[self textAttributes]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];
} }

View File

@@ -69,7 +69,7 @@
_node = [[ASTextNode alloc] init]; _node = [[ASTextNode alloc] init];
_node.maximumNumberOfLines = 3; _node.maximumNumberOfLines = 3;
_node.backgroundColor = [UIColor lightGrayColor]; _node.backgroundColor = [UIColor lightGrayColor];
_node.attributedString = string; _node.attributedText = string;
_node.frame = CGRectMake(70, 400, 40, 100); _node.frame = CGRectMake(70, 400, 40, 100);
// [_node measure:CGSizeMake(40, 50)]; No longer needed now that https://github.com/facebook/AsyncDisplayKit/issues/1295 is fixed. // [_node measure:CGSizeMake(40, 50)]; No longer needed now that https://github.com/facebook/AsyncDisplayKit/issues/1295 is fixed.

View File

@@ -115,7 +115,7 @@
[self setText:[NSString stringWithFormat:@"loaded '%@'", imageIdentifier]]; [self setText:[NSString stringWithFormat:@"loaded '%@'", imageIdentifier]];
if ([imageIdentifier isEqualToString:@"best"]) { if ([imageIdentifier isEqualToString:@"best"]) {
[self setText:[_buttonNode.titleNode.attributedString.string stringByAppendingString:@". tap to reload"]]; [self setText:[_buttonNode.titleNode.attributedText.string stringByAppendingString:@". tap to reload"]];
_buttonNode.userInteractionEnabled = YES; _buttonNode.userInteractionEnabled = YES;
} }
} }

View File

@@ -52,7 +52,7 @@
NSString *text = @"Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh."; NSString *text = @"Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.";
NSDictionary *attributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:17.0] }; NSDictionary *attributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:17.0] };
_textNode.attributedString = [[NSAttributedString alloc] initWithString:text attributes:attributes]; _textNode.attributedText = [[NSAttributedString alloc] initWithString:text attributes:attributes];
_needyChildNode = [[SlowpokeShareNode alloc] init]; _needyChildNode = [[SlowpokeShareNode alloc] init];
_needyChildNode.opaque = NO; _needyChildNode.opaque = NO;

View File

@@ -77,7 +77,7 @@
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.placeholderEnabled = NO; _textNode.placeholderEnabled = NO;
_textNode.attributedString = [[NSAttributedString alloc] initWithString:@"Hello, ASDK!" _textNode.attributedText = [[NSAttributedString alloc] initWithString:@"Hello, ASDK!"
attributes:[self textStyle]]; attributes:[self textStyle]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -63,7 +63,7 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot), NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle | NSUnderlinePatternDot),
} }
range:[blurb rangeOfString:@"placekitten.com"]]; range:[blurb rangeOfString:@"placekitten.com"]];
_textNode.attributedString = string; _textNode.attributedText = string;
// add it as a subnode, and we're done // add it as a subnode, and we're done
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -97,7 +97,7 @@ static const CGFloat kInnerPadding = 10.0f;
// lorem ipsum text, plus some nice styling // lorem ipsum text, plus some nice styling
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:[self kittyIpsum] _textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
attributes:[self textStyle]]; attributes:[self textStyle]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -56,7 +56,7 @@ static NSString *kLinkAttributeName = @"PlaceKittenNodeLinkAttributeName";
// generate an attributed string using the custom link attribute specified above // generate an attributed string using the custom link attribute specified above
NSString *blurb = @"Nic Cage courtesy of himself."; NSString *blurb = @"Nic Cage courtesy of himself.";
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:blurb]; NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:blurb];
_textNode.attributedString = string; _textNode.attributedText = string;
// add it as a subnode, and we're done // add it as a subnode, and we're done
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -122,7 +122,7 @@ static const CGFloat kInnerPadding = 10.0f;
[self addSubnode:_videoNode]; [self addSubnode:_videoNode];
_textNode = [[ASTextNode alloc] init]; _textNode = [[ASTextNode alloc] init];
_textNode.attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@ %@", methodArray[videoInitMethod], autoPlayArray[autoPlay], [self kittyIpsum]] _textNode.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@ %@", methodArray[videoInitMethod], autoPlayArray[autoPlay], [self kittyIpsum]]
attributes:[self textStyle]]; attributes:[self textStyle]];
[self addSubnode:_textNode]; [self addSubnode:_textNode];

View File

@@ -21,7 +21,7 @@
- (void)viewDidLoad - (void)viewDidLoad
{ {
self.textNode = [[ASTextNode alloc] init]; self.textNode = [[ASTextNode alloc] init];
self.textNode.attributedString = [[NSAttributedString alloc] initWithString:@"Testing, testing." attributes:@{ NSForegroundColorAttributeName: [UIColor redColor] }]; self.textNode.attributedText = [[NSAttributedString alloc] initWithString:@"Testing, testing." attributes:@{ NSForegroundColorAttributeName: [UIColor redColor] }];
[self.textNode measure:self.view.bounds.size]; [self.textNode measure:self.view.bounds.size];
self.textNode.frame = (CGRect){ .origin = CGPointZero, .size = self.textNode.calculatedSize }; self.textNode.frame = (CGRect){ .origin = CGPointZero, .size = self.textNode.calculatedSize };
[self.view addSubnode:self.textNode]; [self.view addSubnode:self.textNode];