Skip to content

Commit 1bfbc6b

Browse files
author
Stephanie Sharp
committed
Extract isEqual method out into UIFont category
1 parent daf5fcf commit 1bfbc6b

4 files changed

Lines changed: 43 additions & 6 deletions

File tree

MaterialTextField.xcodeproj/project.pbxproj

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

99
/* Begin PBXBuildFile section */
10+
82125D291BEF36E20017F72C /* UIFont+MaterialTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = 82125D271BEF36E20017F72C /* UIFont+MaterialTextField.h */; };
11+
82125D2A1BEF36E20017F72C /* UIFont+MaterialTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 82125D281BEF36E20017F72C /* UIFont+MaterialTextField.m */; };
1012
CE58F7BD1BEBE64C0082924A /* MaterialTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7BC1BEBE64C0082924A /* MaterialTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
1113
CE58F7C41BEBE64C0082924A /* MaterialTextField.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */; };
1214
CE58F7C91BEBE64C0082924A /* MaterialTextFieldTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7C81BEBE64C0082924A /* MaterialTextFieldTests.m */; };
@@ -31,6 +33,8 @@
3133
/* End PBXContainerItemProxy section */
3234

3335
/* Begin PBXFileReference section */
36+
82125D271BEF36E20017F72C /* UIFont+MaterialTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+MaterialTextField.h"; sourceTree = "<group>"; };
37+
82125D281BEF36E20017F72C /* UIFont+MaterialTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+MaterialTextField.m"; sourceTree = "<group>"; };
3438
CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialTextField.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3539
CE58F7BC1BEBE64C0082924A /* MaterialTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaterialTextField.h; sourceTree = "<group>"; };
3640
CE58F7BE1BEBE64C0082924A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -110,6 +114,8 @@
110114
CE58F7D41BEBE77E0082924A /* MFTextField.m */,
111115
CE58F7D51BEBE77E0082924A /* UIColor+MaterialTextField.h */,
112116
CE58F7D61BEBE77E0082924A /* UIColor+MaterialTextField.m */,
117+
82125D271BEF36E20017F72C /* UIFont+MaterialTextField.h */,
118+
82125D281BEF36E20017F72C /* UIFont+MaterialTextField.m */,
113119
CE58F7D71BEBE77E0082924A /* UIImage+MFTint.h */,
114120
CE58F7D81BEBE77E0082924A /* UIImage+MFTint.m */,
115121
CE58F7D91BEBE77E0082924A /* UITextField+MFClearButton.h */,
@@ -139,6 +145,7 @@
139145
CE58F7DD1BEBE77E0082924A /* UIColor+MaterialTextField.h in Headers */,
140146
CE58F7E11BEBE77E0082924A /* UITextField+MFClearButton.h in Headers */,
141147
CE58F7BD1BEBE64C0082924A /* MaterialTextField.h in Headers */,
148+
82125D291BEF36E20017F72C /* UIFont+MaterialTextField.h in Headers */,
142149
CE58F7DB1BEBE77E0082924A /* MFTextField.h in Headers */,
143150
);
144151
runOnlyForDeploymentPostprocessing = 0;
@@ -243,6 +250,7 @@
243250
CE58F7DE1BEBE77E0082924A /* UIColor+MaterialTextField.m in Sources */,
244251
CE58F7E21BEBE77E0082924A /* UITextField+MFClearButton.m in Sources */,
245252
CE58F7E01BEBE77E0082924A /* UIImage+MFTint.m in Sources */,
253+
82125D2A1BEF36E20017F72C /* UIFont+MaterialTextField.m in Sources */,
246254
);
247255
runOnlyForDeploymentPostprocessing = 0;
248256
};

MaterialTextField/MFTextField.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "MFTextField.h"
1010
#import "UIColor+MaterialTextField.h"
1111
#import "UITextField+MFClearButton.h"
12+
#import "UIFont+MaterialTextField.h"
1213

1314
static CGFloat const MFDefaultLabelFontSize = 13.0f;
1415
static NSTimeInterval const MFDefaultAnimationDuration = 0.3;
@@ -400,7 +401,7 @@ - (UIFont *)defaultFontForPlaceholder
400401

401402
- (void)updateDefaultPlaceholderFont
402403
{
403-
BOOL isUsingDefaultFont = [self font:self.placeholderFont isEqualToFont:self.defaultPlaceholderFont];
404+
BOOL isUsingDefaultFont = [self.placeholderFont isEqual:self.defaultPlaceholderFont];
404405

405406
self.defaultPlaceholderFont = [self defaultFontForPlaceholder];
406407

@@ -409,11 +410,6 @@ - (void)updateDefaultPlaceholderFont
409410
}
410411
}
411412

412-
- (BOOL)font:(UIFont *)font1 isEqualToFont:(UIFont *)font2
413-
{
414-
return [[[font1 fontDescriptor] fontAttributes] isEqual:[[font2 fontDescriptor] fontAttributes]];
415-
}
416-
417413
- (void)showPlaceholderLabelAnimated:(BOOL)animated
418414
{
419415
if (self.placeholderAnimatesOnFocus) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// UIFont+MaterialTextField.h
3+
// MaterialTextField
4+
//
5+
// Created by Steph Sharp on 8/11/2015.
6+
// Copyright © 2015 Stephanie Sharp. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface UIFont (MaterialTextField)
12+
13+
- (BOOL)isEqual:(UIFont *)font;
14+
15+
@end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// UIFont+MaterialTextField.m
3+
// MaterialTextField
4+
//
5+
// Created by Steph Sharp on 8/11/2015.
6+
// Copyright © 2015 Stephanie Sharp. All rights reserved.
7+
//
8+
9+
#import "UIFont+MaterialTextField.h"
10+
11+
@implementation UIFont (MaterialTextField)
12+
13+
- (BOOL)isEqual:(UIFont *)font
14+
{
15+
return [[[self fontDescriptor] fontAttributes] isEqual:[[font fontDescriptor] fontAttributes]];
16+
}
17+
18+
@end

0 commit comments

Comments
 (0)