mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Improve ASButtonNode layout invalidation
This commit is contained in:
@@ -142,6 +142,7 @@
|
||||
[self updateBackgroundImage];
|
||||
[self updateImage];
|
||||
[self updateTitle];
|
||||
[self invalidateSize];
|
||||
}
|
||||
|
||||
- (void)setDisplaysAsynchronously:(BOOL)displaysAsynchronously
|
||||
@@ -172,7 +173,6 @@
|
||||
if ((_imageNode != nil || newImage != nil) && newImage != self.imageNode.image) {
|
||||
_imageNode.image = newImage;
|
||||
[self setNeedsLayout];
|
||||
[self invalidateSize];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,6 @@
|
||||
_titleNode.attributedText = newTitle;
|
||||
self.accessibilityLabel = _titleNode.accessibilityLabel;
|
||||
[self setNeedsLayout];
|
||||
[self invalidateSize];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +219,6 @@
|
||||
if ((_backgroundImageNode != nil || newImage != nil) && newImage != self.backgroundImageNode.image) {
|
||||
_backgroundImageNode.image = newImage;
|
||||
[self setNeedsLayout];
|
||||
[self invalidateSize];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,6 +530,7 @@
|
||||
- (void)layout
|
||||
{
|
||||
[super layout];
|
||||
|
||||
_backgroundImageNode.hidden = (_backgroundImageNode.image == nil);
|
||||
_imageNode.hidden = (_imageNode.image == nil);
|
||||
_titleNode.hidden = (_titleNode.attributedText.length == 0);
|
||||
|
||||
@@ -61,11 +61,7 @@
|
||||
|
||||
_buttonNode = [[ASButtonNode alloc] init];
|
||||
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:buttonColor forState:ASControlStateNormal];
|
||||
|
||||
// Note: Currently we have to set all the button properties to the same one as for ASControlStateNormal. Otherwise
|
||||
// if the button is involved in the layout transition it would break the transition as it does a layout pass
|
||||
// while changing the title. This needs and will be fixed in the future!
|
||||
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:buttonColor forState:ASControlStateHighlighted];
|
||||
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:[buttonColor colorWithAlphaComponent:0.5] forState:ASControlStateHighlighted];
|
||||
|
||||
|
||||
// Some debug colors
|
||||
@@ -80,7 +76,7 @@
|
||||
{
|
||||
[super didLoad];
|
||||
|
||||
[self.buttonNode addTarget:self action:@selector(buttonPressed:) forControlEvents:ASControlNodeEventTouchDown];
|
||||
[self.buttonNode addTarget:self action:@selector(buttonPressed:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
Reference in New Issue
Block a user