mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Improve ASButtonNode layout invalidation
This commit is contained in:
@@ -142,6 +142,7 @@
|
|||||||
[self updateBackgroundImage];
|
[self updateBackgroundImage];
|
||||||
[self updateImage];
|
[self updateImage];
|
||||||
[self updateTitle];
|
[self updateTitle];
|
||||||
|
[self invalidateSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDisplaysAsynchronously:(BOOL)displaysAsynchronously
|
- (void)setDisplaysAsynchronously:(BOOL)displaysAsynchronously
|
||||||
@@ -172,7 +173,6 @@
|
|||||||
if ((_imageNode != nil || newImage != nil) && newImage != self.imageNode.image) {
|
if ((_imageNode != nil || newImage != nil) && newImage != self.imageNode.image) {
|
||||||
_imageNode.image = newImage;
|
_imageNode.image = newImage;
|
||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
[self invalidateSize];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,6 @@
|
|||||||
_titleNode.attributedText = newTitle;
|
_titleNode.attributedText = newTitle;
|
||||||
self.accessibilityLabel = _titleNode.accessibilityLabel;
|
self.accessibilityLabel = _titleNode.accessibilityLabel;
|
||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
[self invalidateSize];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +219,6 @@
|
|||||||
if ((_backgroundImageNode != nil || newImage != nil) && newImage != self.backgroundImageNode.image) {
|
if ((_backgroundImageNode != nil || newImage != nil) && newImage != self.backgroundImageNode.image) {
|
||||||
_backgroundImageNode.image = newImage;
|
_backgroundImageNode.image = newImage;
|
||||||
[self setNeedsLayout];
|
[self setNeedsLayout];
|
||||||
[self invalidateSize];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,6 +530,7 @@
|
|||||||
- (void)layout
|
- (void)layout
|
||||||
{
|
{
|
||||||
[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.attributedText.length == 0);
|
_titleNode.hidden = (_titleNode.attributedText.length == 0);
|
||||||
|
|||||||
@@ -61,11 +61,7 @@
|
|||||||
|
|
||||||
_buttonNode = [[ASButtonNode alloc] init];
|
_buttonNode = [[ASButtonNode alloc] init];
|
||||||
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:buttonColor forState:ASControlStateNormal];
|
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:buttonColor forState:ASControlStateNormal];
|
||||||
|
[_buttonNode setTitle:buttonTitle withFont:buttonFont withColor:[buttonColor colorWithAlphaComponent:0.5] forState:ASControlStateHighlighted];
|
||||||
// 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];
|
|
||||||
|
|
||||||
|
|
||||||
// Some debug colors
|
// Some debug colors
|
||||||
@@ -80,7 +76,7 @@
|
|||||||
{
|
{
|
||||||
[super didLoad];
|
[super didLoad];
|
||||||
|
|
||||||
[self.buttonNode addTarget:self action:@selector(buttonPressed:) forControlEvents:ASControlNodeEventTouchDown];
|
[self.buttonNode addTarget:self action:@selector(buttonPressed:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Actions
|
#pragma mark - Actions
|
||||||
|
|||||||
Reference in New Issue
Block a user