forked from fdzsergio/SFFocusViewLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSFCollectionViewCell.m
More file actions
44 lines (30 loc) · 1.02 KB
/
SFCollectionViewCell.m
File metadata and controls
44 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// SFCollectionViewCell.m
// SFFocusViewLayout
//
// Created by Sergio Fernández Durán on 10/5/15.
// Copyright © 2015 Sergio Fernández. All rights reserved.
//
#import "SFCollectionViewCell.h"
@interface SFCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UIView *overlayView;
@end
@implementation SFCollectionViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
[super applyLayoutAttributes:layoutAttributes];
CGFloat featuredHeight = 280.f;
CGFloat standardHeight = 100.f;
CGFloat delta = 1 - ((featuredHeight - CGRectGetHeight(self.frame)) / (featuredHeight - standardHeight));
CGFloat minAlpha = 0.3f;
CGFloat maxAlpha = 0.75f;
CGFloat alpha = maxAlpha - (delta * (maxAlpha - minAlpha));
self.overlayView.alpha = alpha;
CGFloat scale = MAX(delta, 0.5f);
self.titleLabel.transform = CGAffineTransformMakeScale(scale, scale);
self.descriptionLabel.alpha = delta;
}
@end