Skip to content

Commit 8836f88

Browse files
author
Junius Gunaratne
committed
[Pesto] Use a MDCShadowLayer under the flexible header instead of a UIKit shadow
Reviewers: traviskaufman, ajsecord, iangordon, #material_components_ios_owners Reviewed By: iangordon, #material_components_ios_owners Subscribers: featherless Projects: #material_components_ios Differential Revision: http://codereview.cc/D134
1 parent bff3c13 commit 8836f88

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

demos/Pesto/Pesto/PestoCardCollectionViewCell.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ - (void)layoutSubviews {
8080
- (void)prepareForReuse {
8181
[super prepareForReuse];
8282

83-
for (UIView *subview in [self.contentView subviews]) {
84-
[subview removeFromSuperview];
85-
}
86-
8783
_author = nil;
8884
_icon = nil;
8985
_imageURL = nil;
9086
_title = nil;
87+
_image = nil;
88+
_imageView.image = nil;
9189
}
9290

9391
+ (Class)layerClass {

demos/Pesto/Pesto/PestoCollectionViewController.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#import "PestoData.h"
44
#import "PestoRemoteImageService.h"
55

6+
#import "MaterialShadowElevations.h"
7+
#import "MaterialShadowLayer.h"
8+
69
static CGFloat kPestoCollectionViewControllerAnimationDuration = 0.33f;
710
static CGFloat kPestoCollectionViewControllerDefaultHeaderHeight = 240.f;
811
static CGFloat kPestoCollectionViewControllerInset = 5.f;
@@ -40,6 +43,12 @@ - (void)setFlexHeaderContainerVC:(MDCFlexibleHeaderContainerViewController *)fle
4043
headerView.maximumHeight = kPestoCollectionViewControllerDefaultHeaderHeight;
4144
headerView.minimumHeight = kPestoCollectionViewControllerSmallHeaderHeight;
4245
[headerView.contentView addSubview:[self pestoHeaderView]];
46+
47+
// Use a custom shadow under the flexible header.
48+
MDCShadowLayer *shadowLayer = [MDCShadowLayer layer];
49+
shadowLayer.shadowMaskEnabled = NO;
50+
[shadowLayer setElevation:MDCShadowElevationNone];
51+
headerView.shadowLayer = shadowLayer;
4352
}
4453

4554
- (void)viewWillAppear:(BOOL)animated {
@@ -158,6 +167,11 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
158167
}];
159168
}
160169
_logoView.transform = CGAffineTransformScale(CGAffineTransformIdentity, _logoScale, _logoScale);
170+
171+
MDCFlexibleHeaderView *headerView = _flexHeaderContainerVC.headerViewController.headerView;
172+
MDCShadowLayer *shadowLayer = (MDCShadowLayer *)headerView.shadowLayer;
173+
CGFloat elevation = MDCShadowElevationAppBar * headerView.shadowIntensity;
174+
[shadowLayer setElevation:elevation];
161175
}
162176

163177
#pragma mark - Private methods

0 commit comments

Comments
 (0)