mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-04 03:40:45 +00:00
Node init performance: Use share instances of UIColor and NSAttributedString for defaults.
This commit is contained in:
parent
15975a67e8
commit
f7e94f42ed
@ -60,6 +60,7 @@ extern id ASDisplayNodeFindFirstSubnode(ASDisplayNode *start, BOOL (^block)(ASDi
|
|||||||
extern id ASDisplayNodeFindFirstSubnodeOfClass(ASDisplayNode *start, Class c);
|
extern id ASDisplayNodeFindFirstSubnodeOfClass(ASDisplayNode *start, Class c);
|
||||||
|
|
||||||
extern UIColor *ASDisplayNodeDefaultPlaceholderColor();
|
extern UIColor *ASDisplayNodeDefaultPlaceholderColor();
|
||||||
|
extern UIColor *ASDisplayNodeDefaultTintColor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Disable willAppear / didAppear / didDisappear notifications for a sub-hierarchy, then re-enable when done. Nested calls are supported.
|
Disable willAppear / didAppear / didDisappear notifications for a sub-hierarchy, then re-enable when done. Nested calls are supported.
|
||||||
|
@ -126,7 +126,24 @@ extern id ASDisplayNodeFindFirstSubnodeOfClass(ASDisplayNode *start, Class c)
|
|||||||
|
|
||||||
UIColor *ASDisplayNodeDefaultPlaceholderColor()
|
UIColor *ASDisplayNodeDefaultPlaceholderColor()
|
||||||
{
|
{
|
||||||
return [UIColor colorWithWhite:0.95 alpha:1.0];
|
static UIColor *defaultPlaceholderColor;
|
||||||
|
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
defaultPlaceholderColor = [UIColor colorWithWhite:0.95 alpha:1.0];
|
||||||
|
});
|
||||||
|
return defaultPlaceholderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIColor *ASDisplayNodeDefaultTintColor()
|
||||||
|
{
|
||||||
|
static UIColor *defaultTintColor;
|
||||||
|
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
defaultTintColor = [UIColor colorWithRed:0.0 green:0.478 blue:1.0 alpha:1.0];
|
||||||
|
});
|
||||||
|
return defaultTintColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Hierarchy Notifications
|
#pragma mark - Hierarchy Notifications
|
||||||
|
@ -130,7 +130,7 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
|||||||
self.needsDisplayOnBoundsChange = YES;
|
self.needsDisplayOnBoundsChange = YES;
|
||||||
|
|
||||||
_truncationMode = NSLineBreakByWordWrapping;
|
_truncationMode = NSLineBreakByWordWrapping;
|
||||||
_truncationAttributedString = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"\u2026", @"Default truncation string")];
|
_truncationAttributedString = DefaultTruncationAttributedString();
|
||||||
|
|
||||||
// The common case is for a text node to be non-opaque and blended over some background.
|
// The common case is for a text node to be non-opaque and blended over some background.
|
||||||
self.opaque = NO;
|
self.opaque = NO;
|
||||||
@ -972,6 +972,16 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
|||||||
|
|
||||||
#pragma mark - Truncation Message
|
#pragma mark - Truncation Message
|
||||||
|
|
||||||
|
static NSAttributedString *DefaultTruncationAttributedString()
|
||||||
|
{
|
||||||
|
static NSAttributedString *defaultTruncationAttributedString;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
defaultTruncationAttributedString = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"\u2026", @"Default truncation string")];
|
||||||
|
});
|
||||||
|
return defaultTruncationAttributedString;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setTruncationAttributedString:(NSAttributedString *)truncationAttributedString
|
- (void)setTruncationAttributedString:(NSAttributedString *)truncationAttributedString
|
||||||
{
|
{
|
||||||
// No-op if they're exactly equal (avoid redrawing)
|
// No-op if they're exactly equal (avoid redrawing)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user