mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-14 21:08:48 +00:00
Summary: Updated IGListCollectionView:initWithFrame:collectionViewLayout constructor to support UIAppearance for the backgroundColor property. Fixes #294 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes https://github.com/Instagram/IGListKit/pull/298 Differential Revision: D4292394 Pulled By: rnystrom fbshipit-source-id: a7c4f0e516728b684993f2651eadcc25001de783
38 lines
1.3 KiB
Objective-C
38 lines
1.3 KiB
Objective-C
/**
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import "IGListCollectionView.h"
|
|
|
|
@implementation IGListCollectionView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
|
|
if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
|
|
|
|
UIColor *backgroundAppearanceColor = (UIColor *) [[[self class] appearance] backgroundColor];
|
|
if (!backgroundAppearanceColor) {
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
}
|
|
|
|
self.alwaysBounceVertical = YES;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)layoutSubviews {
|
|
/**
|
|
UICollectionView will sometimes lay its cells out with an animation. This is especially noticeable on older devices
|
|
while scrolling quickly. The simplest fix is to just disable animations for -layoutSubviews, which is where cells
|
|
and other views inside the UICollectionView are laid out.
|
|
*/
|
|
[UIView performWithoutAnimation:^{
|
|
[super layoutSubviews];
|
|
}];
|
|
}
|
|
|
|
@end
|