Skip to content

Commit 494cfc6

Browse files
committed
Separated thumbnail spacing vars
1 parent 7377d15 commit 494cfc6

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

2-
ise
2+
# Noise
33
*.mode1v3
44
*.pbxuser
55
*.perspective
6+
*.xcuserstate
7+
*.xcsettings
8+
*.xcscheme
9+
*.xcworkspacedata
610
*.perspectivev3
711
*.pyc
812
*~.nib/
913
build/*
10-
*.xcuserstate
11-
*.xcsettings
1214

1315
# old school
1416
.svn

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
450A5DEA14408E97003C452F /* README in Resources */ = {isa = PBXBuildFile; fileRef = 450A5DE914408E97003C452F /* README */; };
10+
4515DF421449EB19009CBCA4 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 4515DF411449EB19009CBCA4 /* README.md */; };
1111
4523F21A13B7181800C883E5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4523F21913B7181800C883E5 /* UIKit.framework */; };
1212
4523F21C13B7181900C883E5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4523F21B13B7181900C883E5 /* Foundation.framework */; };
1313
4523F21E13B7181900C883E5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4523F21D13B7181900C883E5 /* CoreGraphics.framework */; };
@@ -28,7 +28,7 @@
2828
/* End PBXBuildFile section */
2929

3030
/* Begin PBXFileReference section */
31-
450A5DE914408E97003C452F /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README; path = ../README; sourceTree = "<group>"; };
31+
4515DF411449EB19009CBCA4 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = "<group>"; };
3232
4523F21513B7181800C883E5 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
3333
4523F21913B7181800C883E5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
3434
4523F21B13B7181900C883E5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -75,7 +75,7 @@
7575
4523F20A13B7181800C883E5 = {
7676
isa = PBXGroup;
7777
children = (
78-
450A5DE914408E97003C452F /* README */,
78+
4515DF411449EB19009CBCA4 /* README.md */,
7979
4523F21F13B7181900C883E5 /* Demo */,
8080
4523F21813B7181800C883E5 /* Frameworks */,
8181
4523F21613B7181800C883E5 /* Products */,
@@ -210,7 +210,7 @@
210210
45EFADB11402983300A0D5E8 /* check.png in Resources */,
211211
45EFADB21402983300A0D5E8 /* [email protected] in Resources */,
212212
45EFADB31402983300A0D5E8 /* [email protected] in Resources */,
213-
450A5DEA14408E97003C452F /* README in Resources */,
213+
4515DF421449EB19009CBCA4 /* README.md in Resources */,
214214
);
215215
runOnlyForDeploymentPostprocessing = 0;
216216
};

VCThumbnailGridView/VCThumbnailGridView.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ - (void)reloadData {
109109
}
110110
_numberOfThumbnailsInRow = MAX(_numberOfThumbnailsInRow, 1);
111111

112-
CGFloat width = (self.bounds.size.width - (4 * (_numberOfThumbnailsInRow+1))) / _numberOfThumbnailsInRow;
113-
_tableView.rowHeight = width + 4;
112+
CGFloat gap = 4.0f;
113+
CGFloat width = (self.bounds.size.width - (gap * (_numberOfThumbnailsInRow+1))) / _numberOfThumbnailsInRow;
114+
_tableView.rowHeight = width + gap;
114115

115116
[_tableView reloadData];
116117
}

VCThumbnailGridView/VCThumbnailViewCell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
@property (nonatomic, retain) NSMutableArray *thumbnails;
3838
@property (nonatomic) NSInteger thumbnailCount;
3939
@property (nonatomic) CGSize thumbnailSize;
40+
@property (nonatomic) CGFloat thumbnailSpacing;
4041

4142
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier thumbnailCount:(NSInteger)count;
4243

VCThumbnailGridView/VCThumbnailViewCell.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ @implementation VCThumbnailViewCell
3131
@synthesize thumbnails = _thumbnails;
3232
@synthesize thumbnailCount = _thumbnailCount;
3333
@synthesize thumbnailSize = _thumbnailSize;
34+
@synthesize thumbnailSpacing = _thumbnailSpacing;
3435

3536
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier thumbnailCount:(NSInteger)count
3637
{
3738
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
3839
if (self) {
3940
self.thumbnailCount = count;
40-
CGFloat screenwidth = 320;
41-
CGFloat gap = 4;
42-
CGFloat width = (screenwidth - (gap * (self.thumbnailCount + 1))) / self.thumbnailCount;
41+
CGFloat screenwidth = self.bounds.size.width;
42+
_thumbnailSpacing = 4.0f;
43+
CGFloat width = (screenwidth - (_thumbnailSpacing * (self.thumbnailCount + 1))) / self.thumbnailCount;
4344
self.thumbnailSize = CGSizeMake(width, width);
4445

4546
_thumbnails = [[NSMutableArray alloc] initWithCapacity:self.thumbnailCount];
@@ -52,7 +53,10 @@ - (void)layoutSubviews
5253
VCThumbnailView *thumbnailButton = nil;
5354
for (int counter = 0; counter < [self.thumbnails count]; counter++) {
5455
thumbnailButton = [_thumbnails objectAtIndex:counter];
55-
thumbnailButton.frame = CGRectMake(4 + (counter * (self.thumbnailSize.width + 4)), 2, self.thumbnailSize.width, self.thumbnailSize.height);
56+
thumbnailButton.frame = CGRectMake(_thumbnailSpacing + (counter * (self.thumbnailSize.width + _thumbnailSpacing)),
57+
_thumbnailSpacing/2,
58+
self.thumbnailSize.width,
59+
self.thumbnailSize.height);
5660
}
5761
}
5862

0 commit comments

Comments
 (0)