mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix ASTableNode / ASCollectionNode backgroundColor does not work
If the background color is applied via the pending state it's applied to the layer of the UICollectionView / UITableview. Unfortunately UITableView / UICollectionView does not consider using the layer backgroundColor property as it's background color, so it needs to be applied to the view after the ASCollectionNode / ASTableNode did load and the view is available
This commit is contained in:
@@ -16,6 +16,11 @@
|
||||
@interface _ASCollectionPendingState : NSObject
|
||||
@property (weak, nonatomic) id <ASCollectionDelegate> delegate;
|
||||
@property (weak, nonatomic) id <ASCollectionDataSource> dataSource;
|
||||
|
||||
// If the background color is applied via the pending state it's applied to the layer of the UICollectionView.
|
||||
// Unfortunately UICollectionView does not consider using the layer backgroundColor property as it's background color,
|
||||
// so it needs to be applied to the view after the ASCollectionNode did load and the view is available
|
||||
@property (strong, nonatomic) UIColor *backgroundColor;
|
||||
@end
|
||||
|
||||
@implementation _ASCollectionPendingState
|
||||
@@ -162,6 +167,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
_pendingState.backgroundColor = backgroundColor;
|
||||
} else {
|
||||
ASDisplayNodeAssert([self isNodeLoaded], @"ASTableNode should be loaded if pendingState doesn't exist");
|
||||
self.view.backgroundColor = backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIColor *)backgroundColor
|
||||
{
|
||||
if ([self pendingState]) {
|
||||
return _pendingState.backgroundColor;
|
||||
} else {
|
||||
return self.view.backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
- (ASCollectionView *)view
|
||||
{
|
||||
return (ASCollectionView *)[super view];
|
||||
|
||||
Reference in New Issue
Block a user