Skip to content

Commit

Permalink
Factorized init code in common init method
Browse files Browse the repository at this point in the history
  • Loading branch information
kettch committed May 31, 2016
1 parent 6a74231 commit fda132c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions JNWCollectionView/JNWCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,7 @@ - (instancetype)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self == nil) return nil;

self.wantsLayer = YES;
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay;

_backgroundView = [[JNWCollectionViewCellBackgroundView alloc] initWithFrame:self.bounds];
_backgroundView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;

_crossfadeDuration = 0.25;

[self addSubview:_backgroundView positioned:NSWindowBelow relativeTo:_contentView];
[self _commonInit];

return self;
}
Expand All @@ -95,17 +87,21 @@ - (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self == nil) return nil;

[self _commonInit];

return self;
}

- (void)_commonInit {
self.wantsLayer = YES;
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay;

_backgroundView = [[JNWCollectionViewCellBackgroundView alloc] initWithFrame:self.bounds];
_backgroundView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;

_crossfadeDuration = 0.25;

[self addSubview:_backgroundView positioned:NSWindowBelow relativeTo:nil];

return self;
}

- (void)prepareForReuse {
Expand Down

0 comments on commit fda132c

Please sign in to comment.