Skip to content

Commit 1bb420a

Browse files
author
Junius Gunaratne
committed
Update Pesto to use MDCFlexibleHeader instead of custom flexible header
Summary: Update Pesto to use MDCFlexibleHeader instead of custom flexible header Reviewers: traviskaufman, #material_components_ios_owners, ajsecord Reviewed By: #material_components_ios_owners, ajsecord Projects: #material_components_ios Differential Revision: http://codereview.cc/D130
1 parent cdc746a commit 1bb420a

22 files changed

+551
-512
lines changed

demos/Pesto/Pesto.xcodeproj/project.pbxproj

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
C91F6A501C63A80F00EB4BA8 /* PestoRemoteImageService.m in Sources */ = {isa = PBXBuildFile; fileRef = C91F6A4F1C63A80F00EB4BA8 /* PestoRemoteImageService.m */; };
1212
C9A8552B1C4EDFAA003CADF7 /* PestoSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C9A8552A1C4EDFAA003CADF7 /* PestoSettingsViewController.m */; };
1313
CE6A9B25D9A958C060ABB21D /* libPods-Pesto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D8C7972AFCDCD5C9447F8E /* libPods-Pesto.a */; };
14+
DE3620651C73A0850026DF5D /* PestoCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE3620641C73A0850026DF5D /* PestoCollectionViewController.m */; };
1415
DE381E1A1C457CEE00019C1D /* PestoCardCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DE381E191C457CEE00019C1D /* PestoCardCollectionViewCell.m */; };
1516
DE381E401C45A9FB00019C1D /* PestoSideView.m in Sources */ = {isa = PBXBuildFile; fileRef = DE381E3F1C45A9FB00019C1D /* PestoSideView.m */; };
1617
DE5EF8671C404E0E00D2D4B9 /* PestoDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE5EF8661C404E0E00D2D4B9 /* PestoDetailViewController.m */; };
18+
DEA791031C751D0D006301CC /* PestoData.m in Sources */ = {isa = PBXBuildFile; fileRef = DEA791021C751D0D006301CC /* PestoData.m */; };
19+
DEA791051C752B6A006301CC /* PestoFlexibleHeaderContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEA791041C752B6A006301CC /* PestoFlexibleHeaderContainerViewController.m */; };
1720
DEBEDF291C3EF5D5004B614B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DEBEDF281C3EF5D5004B614B /* main.m */; };
1821
DEBEDF2C1C3EF5D5004B614B /* PestoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DEBEDF2B1C3EF5D5004B614B /* PestoAppDelegate.m */; };
19-
DEBEDF2F1C3EF5D5004B614B /* PestoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEBEDF2E1C3EF5D5004B614B /* PestoViewController.m */; };
2022
DEBEDF321C3EF5D5004B614B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DEBEDF301C3EF5D5004B614B /* Main.storyboard */; };
2123
DEBEDF341C3EF5D5004B614B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DEBEDF331C3EF5D5004B614B /* Assets.xcassets */; };
2224
DEBEDF371C3EF5D5004B614B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DEBEDF351C3EF5D5004B614B /* LaunchScreen.storyboard */; };
@@ -32,18 +34,22 @@
3234
C9A855291C4EDFAA003CADF7 /* PestoSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PestoSettingsViewController.h; sourceTree = "<group>"; };
3335
C9A8552A1C4EDFAA003CADF7 /* PestoSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoSettingsViewController.m; sourceTree = "<group>"; };
3436
D36B00D81356A416449940A7 /* Pods-Pesto.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Pesto.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Pesto/Pods-Pesto.debug.xcconfig"; sourceTree = "<group>"; };
37+
DE3620631C73A0710026DF5D /* PestoCollectionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoCollectionViewController.h; sourceTree = "<group>"; };
38+
DE3620641C73A0850026DF5D /* PestoCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoCollectionViewController.m; sourceTree = "<group>"; };
3539
DE381E181C457CE300019C1D /* PestoCardCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoCardCollectionViewCell.h; sourceTree = "<group>"; };
3640
DE381E191C457CEE00019C1D /* PestoCardCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoCardCollectionViewCell.m; sourceTree = "<group>"; };
3741
DE381E3E1C45A9FB00019C1D /* PestoSideView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PestoSideView.h; sourceTree = "<group>"; };
3842
DE381E3F1C45A9FB00019C1D /* PestoSideView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoSideView.m; sourceTree = "<group>"; };
3943
DE5EF8651C404DFD00D2D4B9 /* PestoDetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoDetailViewController.h; sourceTree = "<group>"; };
4044
DE5EF8661C404E0E00D2D4B9 /* PestoDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoDetailViewController.m; sourceTree = "<group>"; };
45+
DEA791011C751D00006301CC /* PestoData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoData.h; sourceTree = "<group>"; };
46+
DEA791021C751D0D006301CC /* PestoData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoData.m; sourceTree = "<group>"; };
47+
DEA791041C752B6A006301CC /* PestoFlexibleHeaderContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PestoFlexibleHeaderContainerViewController.m; sourceTree = "<group>"; };
48+
DEA791061C752B74006301CC /* PestoFlexibleHeaderContainerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoFlexibleHeaderContainerViewController.h; sourceTree = "<group>"; };
4149
DEBEDF241C3EF5D5004B614B /* Pesto.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pesto.app; sourceTree = BUILT_PRODUCTS_DIR; };
4250
DEBEDF281C3EF5D5004B614B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4351
DEBEDF2A1C3EF5D5004B614B /* PestoAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoAppDelegate.h; sourceTree = "<group>"; };
4452
DEBEDF2B1C3EF5D5004B614B /* PestoAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PestoAppDelegate.m; sourceTree = "<group>"; };
45-
DEBEDF2D1C3EF5D5004B614B /* PestoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PestoViewController.h; sourceTree = "<group>"; };
46-
DEBEDF2E1C3EF5D5004B614B /* PestoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PestoViewController.m; sourceTree = "<group>"; };
4753
DEBEDF311C3EF5D5004B614B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4854
DEBEDF331C3EF5D5004B614B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4955
DEBEDF361C3EF5D5004B614B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -112,15 +118,19 @@
112118
DE5EF8661C404E0E00D2D4B9 /* PestoDetailViewController.m */,
113119
DE381E3E1C45A9FB00019C1D /* PestoSideView.h */,
114120
DE381E3F1C45A9FB00019C1D /* PestoSideView.m */,
115-
DEBEDF2D1C3EF5D5004B614B /* PestoViewController.h */,
116-
DEBEDF2E1C3EF5D5004B614B /* PestoViewController.m */,
117121
C9A855291C4EDFAA003CADF7 /* PestoSettingsViewController.h */,
118122
C9A8552A1C4EDFAA003CADF7 /* PestoSettingsViewController.m */,
119123
C91F6A481C62BC0400EB4BA8 /* PestoAvatarView.h */,
120124
C91F6A491C62BC0400EB4BA8 /* PestoAvatarView.m */,
121125
C91F6A4E1C63A80F00EB4BA8 /* PestoRemoteImageService.h */,
122126
C91F6A4F1C63A80F00EB4BA8 /* PestoRemoteImageService.m */,
127+
DEA791011C751D00006301CC /* PestoData.h */,
128+
DEA791021C751D0D006301CC /* PestoData.m */,
123129
DEBEDF271C3EF5D5004B614B /* Supporting Files */,
130+
DE3620631C73A0710026DF5D /* PestoCollectionViewController.h */,
131+
DE3620641C73A0850026DF5D /* PestoCollectionViewController.m */,
132+
DEA791061C752B74006301CC /* PestoFlexibleHeaderContainerViewController.h */,
133+
DEA791041C752B6A006301CC /* PestoFlexibleHeaderContainerViewController.m */,
124134
);
125135
path = Pesto;
126136
sourceTree = "<group>";
@@ -254,15 +264,17 @@
254264
isa = PBXSourcesBuildPhase;
255265
buildActionMask = 2147483647;
256266
files = (
267+
DE3620651C73A0850026DF5D /* PestoCollectionViewController.m in Sources */,
257268
C91F6A501C63A80F00EB4BA8 /* PestoRemoteImageService.m in Sources */,
269+
DEA791051C752B6A006301CC /* PestoFlexibleHeaderContainerViewController.m in Sources */,
258270
C9A8552B1C4EDFAA003CADF7 /* PestoSettingsViewController.m in Sources */,
259271
C91F6A4A1C62BC0400EB4BA8 /* PestoAvatarView.m in Sources */,
260-
DEBEDF2F1C3EF5D5004B614B /* PestoViewController.m in Sources */,
261272
DE381E1A1C457CEE00019C1D /* PestoCardCollectionViewCell.m in Sources */,
262273
DE5EF8671C404E0E00D2D4B9 /* PestoDetailViewController.m in Sources */,
263274
DEBEDF2C1C3EF5D5004B614B /* PestoAppDelegate.m in Sources */,
264275
DE381E401C45A9FB00019C1D /* PestoSideView.m in Sources */,
265276
DEBEDF291C3EF5D5004B614B /* main.m in Sources */,
277+
DEA791031C751D0D006301CC /* PestoData.m in Sources */,
266278
);
267279
runOnlyForDeploymentPostprocessing = 0;
268280
};

demos/Pesto/Pesto/Assets.xcassets/PestoLogoLarge.imageset/Contents.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "pesto_large_logo.pdf",
65
"scale" : "1x"
76
},
87
{
@@ -20,4 +19,4 @@
2019
"version" : 1,
2120
"author" : "xcode"
2221
}
23-
}
22+
}
Binary file not shown.

demos/Pesto/Pesto/Assets.xcassets/PestoLogoSmall.imageset/Contents.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "pesto_small_logo.pdf",
65
"scale" : "1x"
76
},
87
{
@@ -20,4 +19,4 @@
2019
"version" : 1,
2120
"author" : "xcode"
2221
}
23-
}
22+
}
Binary file not shown.

demos/Pesto/Pesto/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
<string>UIInterfaceOrientationLandscapeLeft</string>
3737
<string>UIInterfaceOrientationLandscapeRight</string>
3838
</array>
39+
<key>UIViewControllerBasedStatusBarAppearance</key>
40+
<false/>
3941
</dict>
4042
</plist>

demos/Pesto/Pesto/PestoAppDelegate.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#import "PestoAppDelegate.h"
2-
#import "PestoViewController.h"
2+
#import "PestoFlexibleHeaderContainerViewController.h"
33

44
@interface PestoAppDelegate ()
55

66
@end
77

88
@implementation PestoAppDelegate
99

10-
1110
- (BOOL)application:(UIApplication *)application
1211
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1312

14-
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
15-
self.window.backgroundColor = [UIColor whiteColor];
16-
[self.window makeKeyAndVisible];
13+
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
1714

18-
PestoViewController *pestoVC = [[PestoViewController alloc] init];
19-
[self.window setRootViewController:pestoVC];
15+
PestoFlexibleHeaderContainerViewController *flexHeadContainerVC =
16+
[[PestoFlexibleHeaderContainerViewController alloc] init];
17+
18+
[self.window setRootViewController:flexHeadContainerVC];
19+
[self.window makeKeyAndVisible];
2020

2121
return YES;
2222
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#import <UIKit/UIKit.h>
2+
3+
#import "MaterialFlexibleHeader.h"
4+
#import "PestoCardCollectionViewCell.h"
5+
6+
@protocol PestoCollectionViewControllerDelegate <NSObject>
7+
8+
@optional
9+
10+
- (void)didSelectCell:(PestoCardCollectionViewCell *)cell completion:(void (^)())completionBlock;
11+
12+
@end
13+
14+
@interface PestoCollectionViewController : UICollectionViewController
15+
16+
@property(weak) id<PestoCollectionViewControllerDelegate> delegate;
17+
@property (nonatomic) CGFloat scrollOffsetY;
18+
@property (nonatomic) CGSize cellSize;
19+
@property (nonatomic) MDCFlexibleHeaderContainerViewController *flexHeaderContainerVC;
20+
21+
@end
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#import "PestoCollectionViewController.h"
2+
#import "PestoCardCollectionViewCell.h"
3+
#import "PestoData.h"
4+
#import "PestoRemoteImageService.h"
5+
6+
static CGFloat kPestoCollectionViewControllerAnimationDuration = 0.33f;
7+
static CGFloat kPestoCollectionViewControllerDefaultHeaderHeight = 240.f;
8+
static CGFloat kPestoCollectionViewControllerInset = 5.f;
9+
static CGFloat kPestoCollectionViewControllerSmallHeaderHeight = 120.f;
10+
11+
@interface PestoCollectionViewController ()
12+
13+
@property (nonatomic) CGFloat logoScale;
14+
@property (nonatomic) UIView *logoSmallView;
15+
@property (nonatomic) UIView *logoView;
16+
@property (nonatomic) PestoData *pestoData;
17+
@property (nonatomic) PestoRemoteImageService *imageService;
18+
19+
@end
20+
21+
@implementation PestoCollectionViewController
22+
23+
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout {
24+
self = [super initWithCollectionViewLayout:layout];
25+
if (self) {
26+
self.collectionView.backgroundColor = [UIColor whiteColor];
27+
[self.collectionView registerClass:[PestoCardCollectionViewCell class]
28+
forCellWithReuseIdentifier:@"PestoCardCollectionViewCell"];
29+
self.pestoData = [[PestoData alloc] init];
30+
self.imageService = [PestoRemoteImageService sharedService];
31+
[self setNeedsStatusBarAppearanceUpdate];
32+
}
33+
return self;
34+
}
35+
36+
- (void)setFlexHeaderContainerVC:(MDCFlexibleHeaderContainerViewController *)flexHeaderContainerVC {
37+
_flexHeaderContainerVC = flexHeaderContainerVC;
38+
MDCFlexibleHeaderView *headerView = _flexHeaderContainerVC.headerViewController.headerView;
39+
headerView.trackingScrollView = self.collectionView;
40+
headerView.maximumHeight = kPestoCollectionViewControllerDefaultHeaderHeight;
41+
headerView.minimumHeight = kPestoCollectionViewControllerSmallHeaderHeight;
42+
[headerView.contentView addSubview:[self pestoHeaderView]];
43+
}
44+
45+
- (void)viewWillAppear:(BOOL)animated {
46+
[super viewWillAppear:animated];
47+
}
48+
49+
- (NSInteger)collectionView:(UICollectionView *)view
50+
numberOfItemsInSection:(NSInteger)section {
51+
return [self.pestoData.imageFileNames count];
52+
}
53+
54+
- (BOOL)prefersStatusBarHidden {
55+
return YES;
56+
}
57+
58+
#pragma mark - UICollectionViewDataSource
59+
60+
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
61+
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
62+
PestoCardCollectionViewCell *cell =
63+
[collectionView dequeueReusableCellWithReuseIdentifier:@"PestoCardCollectionViewCell"
64+
forIndexPath:indexPath];
65+
NSInteger itemNum = indexPath.row;
66+
NSString *baseURL = PestoDataBaseURL;
67+
NSString *imageURLString =
68+
[baseURL stringByAppendingString:self.pestoData.imageFileNames[itemNum]];
69+
NSURL *imageURL = [NSURL URLWithString:imageURLString];
70+
71+
cell.title = self.pestoData.titles[itemNum];
72+
cell.author = self.pestoData.authors[itemNum];
73+
cell.imageURL = imageURLString;
74+
cell.icon = self.pestoData.iconNames[itemNum];
75+
[self updateImageViewWithURL:imageURL cell:cell];
76+
[cell setNeedsLayout];
77+
78+
return cell;
79+
}
80+
81+
- (void)updateImageViewWithURL:(NSURL *)imageURL
82+
cell:(PestoCardCollectionViewCell *)cell {
83+
[_imageService fetchImageDataFromURL:imageURL
84+
completion:^(NSData *imageData) {
85+
if (!imageData) {
86+
return;
87+
}
88+
dispatch_async(dispatch_get_main_queue(), ^{
89+
UIImage *image = [UIImage imageWithData:imageData];
90+
UIImage *thumbnailImage =
91+
[_imageService.thumbnailCache objectForKey:imageURL];
92+
cell.image = image;
93+
cell.imageView.image = thumbnailImage;
94+
[cell setNeedsLayout];
95+
});
96+
}];
97+
}
98+
99+
#pragma mark - UICollectionViewDelegate
100+
101+
- (CGSize)collectionView:(UICollectionView *)collectionView
102+
layout:(UICollectionViewLayout *)collectionViewLayout
103+
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
104+
return self.cellSize;
105+
}
106+
107+
- (void)collectionView:(UICollectionView *)collectionView
108+
didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
109+
110+
PestoCardCollectionViewCell *cell =
111+
(PestoCardCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
112+
[self.delegate didSelectCell:cell completion:^{
113+
}];
114+
}
115+
116+
#pragma mark - UIScrollViewDelegate
117+
118+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
119+
_scrollOffsetY = scrollView.contentOffset.y;
120+
[_flexHeaderContainerVC.headerViewController scrollViewDidScroll:scrollView];
121+
CGRect headerFrame = _flexHeaderContainerVC.headerViewController.headerView.bounds;
122+
_logoView.center = CGPointMake(headerFrame.size.width / 2.f,
123+
headerFrame.size.height / 2.f);
124+
_logoSmallView.center = CGPointMake(headerFrame.size.width / 2.f,
125+
headerFrame.size.height / 2.f);
126+
127+
_logoScale = scrollView.contentOffset.y / -kPestoCollectionViewControllerDefaultHeaderHeight;
128+
129+
if (_logoScale < 0.5f) {
130+
_logoScale = 0.5f;
131+
[UIView animateWithDuration:kPestoCollectionViewControllerAnimationDuration
132+
delay:0
133+
options:UIViewAnimationOptionCurveEaseOut
134+
animations:^{
135+
_logoView.layer.opacity = 0;
136+
_logoSmallView.layer.opacity = 1.f;
137+
}
138+
completion:^(BOOL finished){
139+
}];
140+
} else {
141+
[UIView animateWithDuration:kPestoCollectionViewControllerAnimationDuration
142+
delay:0
143+
options:UIViewAnimationOptionCurveEaseOut
144+
animations:^{
145+
_logoView.layer.opacity = 1.f;
146+
_logoSmallView.layer.opacity = 0;
147+
}
148+
completion:^(BOOL finished){
149+
}];
150+
}
151+
_logoView.transform = CGAffineTransformScale(CGAffineTransformIdentity, _logoScale, _logoScale);
152+
}
153+
154+
#pragma mark - Private methods
155+
156+
- (UIView *)pestoHeaderView {
157+
CGRect headerFrame = _flexHeaderContainerVC.headerViewController.headerView.bounds;
158+
UIView *pestoHeaderView = [[UIView alloc] initWithFrame:headerFrame];
159+
UIColor *teal = [UIColor colorWithRed:0 green:0.67f blue:0.55f alpha:1];
160+
pestoHeaderView.backgroundColor = teal;
161+
pestoHeaderView.layer.masksToBounds = YES;
162+
pestoHeaderView.autoresizingMask =
163+
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
164+
165+
UIImage *image = [UIImage imageNamed:@"PestoLogoLarge"];
166+
_logoView = [[UIImageView alloc] initWithImage:image];
167+
_logoView.contentMode = UIViewContentModeScaleAspectFill;
168+
_logoView.center = CGPointMake(pestoHeaderView.frame.size.width / 2,
169+
pestoHeaderView.frame.size.height / 2);
170+
[pestoHeaderView addSubview:_logoView];
171+
172+
UIImage *logoSmallImage = [UIImage imageNamed:@"PestoLogoSmall"];
173+
_logoSmallView = [[UIImageView alloc] initWithImage:logoSmallImage];
174+
_logoSmallView.contentMode = UIViewContentModeScaleAspectFill;
175+
_logoSmallView.layer.opacity = 0;
176+
[pestoHeaderView addSubview:_logoSmallView];
177+
178+
return pestoHeaderView;
179+
}
180+
181+
- (CGSize)cellSize {
182+
CGFloat cellDim = floor((self.view.frame.size.width - (2.f * kPestoCollectionViewControllerInset))
183+
/ 2.f) - (2.f * kPestoCollectionViewControllerInset);
184+
if (cellDim > 320) {
185+
cellDim = floor((self.view.frame.size.width -
186+
(3.f * kPestoCollectionViewControllerInset)) / 3.f) -
187+
(2.f * kPestoCollectionViewControllerInset);
188+
}
189+
self.cellSize = CGSizeMake(cellDim, cellDim);
190+
return CGSizeMake(cellDim, cellDim);
191+
}
192+
193+
@end

demos/Pesto/Pesto/PestoData.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#import <UIKit/UIKit.h>
2+
3+
CG_EXTERN NSString *const PestoDataBaseURL;
4+
5+
@interface PestoData : NSObject
6+
7+
@property(nonatomic) NSArray *authors;
8+
@property(nonatomic) NSArray *iconNames;
9+
@property(nonatomic) NSArray *imageFileNames;
10+
@property(nonatomic) NSArray *titles;
11+
12+
@end

0 commit comments

Comments
 (0)