From 4ff5a6ccd6d2dfad1ae3988ddb595cadcf941096 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Aug 2017 22:05:51 +0100 Subject: [PATCH 01/13] Make button round. --- Pod/Classes/WPMediaCollectionViewCell.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index b4547ef4..793cc009 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -76,15 +76,18 @@ - (void)commonInit _selectionFrame = [[UIView alloc] initWithFrame:self.backgroundView.frame]; _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; - _selectionFrame.layer.borderWidth = 3; + _selectionFrame.layer.borderWidth = 3.0; - CGFloat counterTextSize = [UIFont smallSystemFontSize]; - CGFloat labelSize = (counterTextSize * 2) + 2; + CGFloat labelSize = 21; _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelSize, labelSize)]; - _positionLabel.backgroundColor = [self tintColor]; + _positionLabel.backgroundColor = [UIColor lightGrayColor]; + _positionLabel.layer.borderWidth = 1.0; + _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; + _positionLabel.layer.cornerRadius = 10; + _positionLabel.clipsToBounds = YES; _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; - _positionLabel.font = [UIFont systemFontOfSize:counterTextSize]; + _positionLabel.font = [UIFont systemFontOfSize:13]; [_selectionFrame addSubview:_positionLabel]; From 3ce470f809bbcfda4002ca5cd215d1686a541b6d Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Aug 2017 22:22:44 +0100 Subject: [PATCH 02/13] Update position of selection cell. --- Pod/Classes/WPMediaCollectionViewCell.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 793cc009..17d3e2cd 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -78,8 +78,9 @@ - (void)commonInit _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; _selectionFrame.layer.borderWidth = 3.0; + CGFloat labelMargin = 5.0; CGFloat labelSize = 21; - _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelSize, labelSize)]; + _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelMargin, self.contentView.frame.size.height - (labelSize + labelMargin), labelSize, labelSize)]; _positionLabel.backgroundColor = [UIColor lightGrayColor]; _positionLabel.layer.borderWidth = 1.0; _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; @@ -89,13 +90,12 @@ - (void)commonInit _positionLabel.textAlignment = NSTextAlignmentCenter; _positionLabel.font = [UIFont systemFontOfSize:13]; - [_selectionFrame addSubview:_positionLabel]; + [self.contentView addSubview:_positionLabel]; self.selectedBackgroundView = _selectionFrame; CGFloat labelTextSize = 12.0; CGFloat labelHeight = 30.0; - CGFloat labelMargin = 5.0; CGColorRef topGradientColor = [[UIColor colorWithWhite:0 alpha:0] CGColor]; CGColorRef bottomGradientColor = [[UIColor colorWithWhite:0 alpha:0.5] CGColor]; From df2c7e1b36ded862a4e4c4987b8fe92f1fff95aa Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Aug 2017 22:28:01 +0100 Subject: [PATCH 03/13] Update position/selection indicator state selection. --- Pod/Classes/WPMediaCollectionViewCell.m | 32 +++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 17d3e2cd..acc68bf4 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -79,16 +79,15 @@ - (void)commonInit _selectionFrame.layer.borderWidth = 3.0; CGFloat labelMargin = 5.0; - CGFloat labelSize = 21; + CGFloat labelSize = 20; _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelMargin, self.contentView.frame.size.height - (labelSize + labelMargin), labelSize, labelSize)]; - _positionLabel.backgroundColor = [UIColor lightGrayColor]; _positionLabel.layer.borderWidth = 1.0; - _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; _positionLabel.layer.cornerRadius = 10; _positionLabel.clipsToBounds = YES; _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; _positionLabel.font = [UIFont systemFontOfSize:13]; + [self updatePositionLabelToSelectedState:NO]; [self.contentView addSubview:_positionLabel]; @@ -295,8 +294,11 @@ - (void)setImage:(UIImage *)image animated:(BOOL)animated - (void)setPosition:(NSInteger)position { _position = position; - self.positionLabel.hidden = position == NSNotFound; - self.positionLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)(position)]; + if (position != NSNotFound) { + self.positionLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)(position)]; + } else { + self.positionLabel.text = @""; + } } - (void)setCaption:(NSString *)caption @@ -317,22 +319,28 @@ - (void)setPlaceholderTintColor:(UIColor *)placeholderTintColor - (void)setSelected:(BOOL)selected { [super setSelected:selected]; - if (self.isSelected) { - } else { - self.positionLabel.hidden = YES; - } + [self updatePositionLabelToSelectedState:self.isSelected]; } - (void)tintColorDidChange { [super tintColorDidChange]; _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; - _positionLabel.backgroundColor = [self tintColor]; - if (self.isSelected) { + [self updatePositionLabelToSelectedState:self.isSelected]; +} + +- (void)updatePositionLabelToSelectedState:(BOOL)selected +{ + if (selected) { + _positionLabel.backgroundColor = [self tintColor]; + _positionLabel.layer.borderColor = [self tintColor].CGColor; } else { - + _positionLabel.text = @""; + _positionLabel.backgroundColor = [UIColor lightGrayColor]; + _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; } + } @end From c49ca9d0dc55c7268b8a493a17474255a36c1eac Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Aug 2017 22:46:45 +0100 Subject: [PATCH 04/13] Update position of label and background color. --- Pod/Classes/WPMediaCollectionViewCell.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index acc68bf4..d702fdd3 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -78,11 +78,12 @@ - (void)commonInit _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; _selectionFrame.layer.borderWidth = 3.0; - CGFloat labelMargin = 5.0; + CGFloat labelMargin = 10.0; CGFloat labelSize = 20; _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelMargin, self.contentView.frame.size.height - (labelSize + labelMargin), labelSize, labelSize)]; + _positionLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin; _positionLabel.layer.borderWidth = 1.0; - _positionLabel.layer.cornerRadius = 10; + _positionLabel.layer.cornerRadius = labelSize / 2; _positionLabel.clipsToBounds = YES; _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; @@ -335,9 +336,12 @@ - (void)updatePositionLabelToSelectedState:(BOOL)selected if (selected) { _positionLabel.backgroundColor = [self tintColor]; _positionLabel.layer.borderColor = [self tintColor].CGColor; + _positionLabel.layer.shadowColor = [UIColor colorWithWhite:0 alpha:1].CGColor; + _positionLabel.layer.shadowRadius = 10.0; + _positionLabel.layer.shadowOffset = CGSizeMake(10, 10); } else { _positionLabel.text = @""; - _positionLabel.backgroundColor = [UIColor lightGrayColor]; + _positionLabel.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.7]; _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; } From 0a290d098b1bfd2a894dad5b28286d19c26e0212 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 15 Aug 2017 22:50:12 +0100 Subject: [PATCH 05/13] Make cell appearance in the picker match the appearance full screen. --- Example/WPMediaPicker/AppDelegate.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Example/WPMediaPicker/AppDelegate.m b/Example/WPMediaPicker/AppDelegate.m index 29f43d90..a28c3043 100644 --- a/Example/WPMediaPicker/AppDelegate.m +++ b/Example/WPMediaPicker/AppDelegate.m @@ -33,6 +33,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBackgroundColor:[UIColor colorWithRed:243/255.0f green:246/255.0f blue:248/255.0f alpha:1.0f]]; //Configure color for activity indicator while loading media collection [[UIActivityIndicatorView appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setColor:[UIColor grayColor]]; + + //Configure background color for media cell while loading image. + [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPInputMediaPickerViewController class],nil] setBackgroundColor:[UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]]; return YES; } From fd4e0a1a0d824107a90fd1219924538e43ce405c Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 12:33:52 +0100 Subject: [PATCH 06/13] Only change label state if selection changed. --- Pod/Classes/WPMediaCollectionViewCell.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index f85b9487..829daba9 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -95,7 +95,7 @@ - (void)commonInit self.selectedBackgroundView = _selectionFrame; CGFloat labelTextSize = 12.0; - CGFloat labelHeight = 30.0; + CGFloat labelHeight = 30.0; CGColorRef topGradientColor = [[UIColor colorWithWhite:0 alpha:0] CGColor]; CGColorRef bottomGradientColor = [[UIColor colorWithWhite:0 alpha:0.5] CGColor]; @@ -319,6 +319,9 @@ - (void)setPlaceholderTintColor:(UIColor *)placeholderTintColor - (void)setSelected:(BOOL)selected { + if (selected == self.isSelected) { + return; + } [super setSelected:selected]; [self updatePositionLabelToSelectedState:self.isSelected]; } From 2577c46f7b3fcf896775340d1d12d629894bc38b Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 12:37:42 +0100 Subject: [PATCH 07/13] Remove shadows on label. --- Pod/Classes/WPMediaCollectionViewCell.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 829daba9..2bf0e74e 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -339,9 +339,6 @@ - (void)updatePositionLabelToSelectedState:(BOOL)selected if (selected) { _positionLabel.backgroundColor = [self tintColor]; _positionLabel.layer.borderColor = [self tintColor].CGColor; - _positionLabel.layer.shadowColor = [UIColor colorWithWhite:0 alpha:1].CGColor; - _positionLabel.layer.shadowRadius = 10.0; - _positionLabel.layer.shadowOffset = CGSizeMake(10, 10); } else { _positionLabel.text = @""; _positionLabel.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.7]; From cca3265a2ae74351367d502b8653d9d737eaf881 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 13:59:58 +0100 Subject: [PATCH 08/13] Add shadow view to position label. --- Pod/Classes/WPMediaCollectionViewCell.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 2bf0e74e..c32560f9 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -8,6 +8,7 @@ @interface WPMediaCollectionViewCell () @property (nonatomic, strong) UILabel *positionLabel; +@property (nonatomic, strong) UIView *positionLabelShadowView; @property (nonatomic, strong) UIView *selectionFrame; @property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UILabel *captionLabel; @@ -88,8 +89,19 @@ - (void)commonInit _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; _positionLabel.font = [UIFont systemFontOfSize:13]; + + _positionLabelShadowView = [[UIView alloc] initWithFrame:_positionLabel.frame]; + _positionLabelShadowView.autoresizingMask = _positionLabel.autoresizingMask; + _positionLabelShadowView.backgroundColor = [UIColor clearColor]; + _positionLabelShadowView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:_positionLabelShadowView.bounds cornerRadius:labelSize / 2].CGPath; + _positionLabelShadowView.layer.shadowColor = [UIColor blackColor].CGColor; + _positionLabelShadowView.layer.shadowRadius = 5; + _positionLabelShadowView.layer.shadowOpacity = 0.5; + _positionLabelShadowView.layer.shadowOffset = CGSizeMake(0, 0); + [self updatePositionLabelToSelectedState:NO]; + [self.contentView addSubview:_positionLabelShadowView]; [self.contentView addSubview:_positionLabel]; self.selectedBackgroundView = _selectionFrame; @@ -339,10 +351,12 @@ - (void)updatePositionLabelToSelectedState:(BOOL)selected if (selected) { _positionLabel.backgroundColor = [self tintColor]; _positionLabel.layer.borderColor = [self tintColor].CGColor; + _positionLabelShadowView.hidden = NO; } else { _positionLabel.text = @""; _positionLabel.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.7]; _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; + _positionLabelShadowView.hidden = YES; } } From a53ef28828d50e1f3b50c17501bdb8d379b329fc Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 15:51:28 +0100 Subject: [PATCH 09/13] Add appearance selector for background tint color for selection label. --- Example/WPMediaPicker/AppDelegate.m | 16 +++++++++++++--- Pod/Classes/WPMediaCollectionViewCell.h | 2 ++ Pod/Classes/WPMediaCollectionViewCell.m | 10 +++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Example/WPMediaPicker/AppDelegate.m b/Example/WPMediaPicker/AppDelegate.m index a28c3043..7367c1e7 100644 --- a/Example/WPMediaPicker/AppDelegate.m +++ b/Example/WPMediaPicker/AppDelegate.m @@ -22,7 +22,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} ]; //Configure navigation bar background color - [[UINavigationBar appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBarTintColor:[UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]]; + UIColor *wordPressBlue = [UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]; + [[UINavigationBar appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBarTintColor: wordPressBlue]; //Configure navigation bar items text color [[UINavigationBar appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setTintColor:[UIColor whiteColor]]; //Configure navigation bar title text color @@ -30,12 +31,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( //Configure background color for media scroll view [[UICollectionView appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBackgroundColor:[UIColor colorWithRed:233/255.0f green:239/255.0f blue:243/255.0f alpha:1.0f]]; //Configure background color for media cell while loading image. - [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBackgroundColor:[UIColor colorWithRed:243/255.0f green:246/255.0f blue:248/255.0f alpha:1.0f]]; + UIColor *cellBackgroundColor = [UIColor colorWithRed:243/255.0f green:246/255.0f blue:248/255.0f alpha:1.0f]; + [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setBackgroundColor:cellBackgroundColor]; + [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPInputMediaPickerViewController class],nil] setBackgroundColor:cellBackgroundColor]; + //Configure color for activity indicator while loading media collection [[UIActivityIndicatorView appearanceWhenContainedIn:[WPMediaPickerViewController class],nil] setColor:[UIColor grayColor]]; //Configure background color for media cell while loading image. - [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPInputMediaPickerViewController class],nil] setBackgroundColor:[UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]]; + + UIColor * lightGray = [UIColor colorWithRed:198.0/255.0 green:198.0/255.0 blue:198.0/255.0 alpha:0.7]; + + [[WPMediaCollectionViewCell appearance] setTintColor:wordPressBlue]; + [[WPMediaCollectionViewCell appearance] setPositionLabelUnselectedTintColor:lightGray]; + [[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPInputMediaPickerViewController class],nil] setPositionLabelUnselectedTintColor:lightGray]; + return YES; } diff --git a/Pod/Classes/WPMediaCollectionViewCell.h b/Pod/Classes/WPMediaCollectionViewCell.h index 6f8d2975..843053fe 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.h +++ b/Pod/Classes/WPMediaCollectionViewCell.h @@ -8,4 +8,6 @@ @property (nonatomic, strong) UIColor *placeholderTintColor UI_APPEARANCE_SELECTOR; +@property (nonatomic, strong) UIColor *positionLabelUnselectedTintColor UI_APPEARANCE_SELECTOR; + @end diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index c32560f9..8bee592e 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -55,7 +55,6 @@ - (void)prepareForReuse [self setSelected:NO]; self.imageView.contentMode = UIViewContentModeScaleAspectFill; self.imageView.backgroundColor = self.backgroundColor; - self.placeholderStackView.hidden = YES; self.documentExtensionLabel.text = nil; } @@ -78,9 +77,12 @@ - (void)commonInit _selectionFrame = [[UIView alloc] initWithFrame:self.backgroundView.frame]; _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; _selectionFrame.layer.borderWidth = 3.0; + self.selectedBackgroundView = _selectionFrame; CGFloat labelMargin = 10.0; CGFloat labelSize = 20; + + _positionLabelUnselectedTintColor = [UIColor colorWithRed:198.0/255.0 green:198.0/255.0 blue:198.0/255.0 alpha:0.7]; _positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelMargin, self.contentView.frame.size.height - (labelSize + labelMargin), labelSize, labelSize)]; _positionLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin; _positionLabel.layer.borderWidth = 1.0; @@ -99,12 +101,10 @@ - (void)commonInit _positionLabelShadowView.layer.shadowOpacity = 0.5; _positionLabelShadowView.layer.shadowOffset = CGSizeMake(0, 0); - [self updatePositionLabelToSelectedState:NO]; - [self.contentView addSubview:_positionLabelShadowView]; [self.contentView addSubview:_positionLabel]; - self.selectedBackgroundView = _selectionFrame; + [self updatePositionLabelToSelectedState:NO]; CGFloat labelTextSize = 12.0; CGFloat labelHeight = 30.0; @@ -354,7 +354,7 @@ - (void)updatePositionLabelToSelectedState:(BOOL)selected _positionLabelShadowView.hidden = NO; } else { _positionLabel.text = @""; - _positionLabel.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.7]; + _positionLabel.backgroundColor = _positionLabelUnselectedTintColor; _positionLabel.layer.borderColor = [UIColor whiteColor].CGColor; _positionLabelShadowView.hidden = YES; } From 4e1bb30c0f88625821ca5258cc8e5cb47bd07092 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 21:28:10 +0100 Subject: [PATCH 10/13] Fix font weight and allow auto-shrink. --- Pod/Classes/WPMediaCollectionViewCell.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 8bee592e..9c83584f 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -90,7 +90,9 @@ - (void)commonInit _positionLabel.clipsToBounds = YES; _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; - _positionLabel.font = [UIFont systemFontOfSize:13]; + _positionLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; + _positionLabel.adjustsFontSizeToFitWidth = YES; + _positionLabel.minimumScaleFactor = 0.5; _positionLabelShadowView = [[UIView alloc] initWithFrame:_positionLabel.frame]; _positionLabelShadowView.autoresizingMask = _positionLabel.autoresizingMask; From d467c84287f7a60543ea82254aebb015c49886d1 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 21:42:48 +0100 Subject: [PATCH 11/13] Fix selection border width. --- Pod/Classes/WPMediaCollectionViewCell.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 9c83584f..02947036 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -76,7 +76,7 @@ - (void)commonInit _selectionFrame = [[UIView alloc] initWithFrame:self.backgroundView.frame]; _selectionFrame.layer.borderColor = [[self tintColor] CGColor]; - _selectionFrame.layer.borderWidth = 3.0; + _selectionFrame.layer.borderWidth = 2.0; self.selectedBackgroundView = _selectionFrame; CGFloat labelMargin = 10.0; From 5bcffa4a4f25ddf09d2e5aa819a87ef5cdfd5d0b Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 22:08:23 +0100 Subject: [PATCH 12/13] When position > 99 reduce font size of position label. --- Pod/Classes/WPMediaCollectionViewCell.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 02947036..727069a0 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -91,8 +91,6 @@ - (void)commonInit _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; _positionLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; - _positionLabel.adjustsFontSizeToFitWidth = YES; - _positionLabel.minimumScaleFactor = 0.5; _positionLabelShadowView = [[UIView alloc] initWithFrame:_positionLabel.frame]; _positionLabelShadowView.autoresizingMask = _positionLabel.autoresizingMask; @@ -310,6 +308,8 @@ - (void)setPosition:(NSInteger)position { _position = position; if (position != NSNotFound) { + CGFloat fontSize = position < 100 ? 13.0 : 9.0; + _positionLabel.font = [UIFont systemFontOfSize:fontSize weight:UIFontWeightMedium]; self.positionLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)(position)]; } else { self.positionLabel.text = @""; From 59ee93efc3a590215c29524e0d23785f237e0283 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 16 Aug 2017 22:36:32 +0100 Subject: [PATCH 13/13] Extract constants of font sizes. --- Pod/Classes/WPMediaCollectionViewCell.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/WPMediaCollectionViewCell.m b/Pod/Classes/WPMediaCollectionViewCell.m index 727069a0..4f844172 100644 --- a/Pod/Classes/WPMediaCollectionViewCell.m +++ b/Pod/Classes/WPMediaCollectionViewCell.m @@ -4,6 +4,8 @@ static const NSTimeInterval ThresholdForAnimation = 0.03; static const CGFloat TimeForFadeAnimation = 0.3; +static const CGFloat LabelSmallFontSize = 9; +static const CGFloat LabelRegularFontSize = 13; @interface WPMediaCollectionViewCell () @@ -90,7 +92,6 @@ - (void)commonInit _positionLabel.clipsToBounds = YES; _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; - _positionLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; _positionLabelShadowView = [[UIView alloc] initWithFrame:_positionLabel.frame]; _positionLabelShadowView.autoresizingMask = _positionLabel.autoresizingMask; @@ -308,7 +309,7 @@ - (void)setPosition:(NSInteger)position { _position = position; if (position != NSNotFound) { - CGFloat fontSize = position < 100 ? 13.0 : 9.0; + CGFloat fontSize = position < 100 ? LabelRegularFontSize : LabelSmallFontSize; _positionLabel.font = [UIFont systemFontOfSize:fontSize weight:UIFontWeightMedium]; self.positionLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)(position)]; } else {