├── Screenshots ├── MaterialTextField.gif └── materialtextfield.png ├── MaterialTextFieldDemo ├── MaterialTextFieldDemo │ ├── Images.xcassets │ │ ├── Contents.json │ │ ├── eye.imageset │ │ │ ├── eye@2x.png │ │ │ ├── eye@3x.png │ │ │ └── Contents.json │ │ ├── lock.imageset │ │ │ ├── lock@2x.png │ │ │ ├── lock@3x.png │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── MaterialTextFieldDemoViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Info.plist │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ └── MaterialTextFieldDemoViewController.m └── MaterialTextFieldDemo.xcodeproj │ ├── xcshareddata │ └── xcschemes │ │ └── MaterialTextFieldDemo.xcscheme │ └── project.pbxproj ├── MaterialTextField.xcworkspace ├── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings └── contents.xcworkspacedata ├── .gitignore ├── MaterialTextField ├── UIFont+MaterialTextField.h ├── UITextField+MFClearButton.h ├── MaterialTextField.h ├── UIFont+MaterialTextField.m ├── UIImage+MFTint.h ├── UIColor+MaterialTextField.h ├── Info.plist ├── UIImage+MFTint.m ├── UIColor+MaterialTextField.m ├── UITextField+MFClearButton.m ├── MFTextField.h └── MFTextField.m ├── MaterialTextField.podspec ├── MaterialTextFieldTests ├── Info.plist └── MaterialTextFieldTests.m ├── LICENSE ├── README.md └── MaterialTextField.xcodeproj ├── xcshareddata └── xcschemes │ └── MaterialTextField.xcscheme └── project.pbxproj /Screenshots/MaterialTextField.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/Screenshots/MaterialTextField.gif -------------------------------------------------------------------------------- /Screenshots/materialtextfield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/Screenshots/materialtextfield.png -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/eye.imageset/eye@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/eye.imageset/eye@2x.png -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/eye.imageset/eye@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/eye.imageset/eye@3x.png -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/lock.imageset/lock@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/lock.imageset/lock@2x.png -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/lock.imageset/lock@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephsharp/MaterialTextField/HEAD/MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/lock.imageset/lock@3x.png -------------------------------------------------------------------------------- /MaterialTextField.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X 2 | *.DS_Store 3 | 4 | # Xcode 5 | *.pbxuser 6 | *.mode1v3 7 | *.mode2v3 8 | *.perspectivev3 9 | *.xcuserstate 10 | project.xcworkspace/ 11 | xcuserdata/ 12 | 13 | # Generated files 14 | *.o 15 | *.pyc 16 | 17 | #Python modules 18 | MANIFEST 19 | dist/ 20 | build/ 21 | 22 | # Backup files 23 | *~.nib 24 | 25 | -------------------------------------------------------------------------------- /MaterialTextField.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MaterialTextField.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MaterialTextField/UIFont+MaterialTextField.h: -------------------------------------------------------------------------------- 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 10 | 11 | @interface UIFont (MaterialTextField) 12 | 13 | - (BOOL)isEqual:(UIFont *)font; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /MaterialTextField/UITextField+MFClearButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+MFClearButton.h 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 11/08/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UITextField (MFClearButton) 12 | 13 | - (void)mf_tintClearButton; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /MaterialTextField/MaterialTextField.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 Stephanie Sharp. All rights reserved. 2 | 3 | #import 4 | 5 | FOUNDATION_EXPORT double MaterialTextFieldVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char MaterialTextFieldVersionString[]; 7 | 8 | #import 9 | #import 10 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/MaterialTextFieldDemoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MaterialTextFieldDemoViewController.h 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MaterialTextFieldDemoViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MaterialTextField/UIFont+MaterialTextField.m: -------------------------------------------------------------------------------- 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 19 | -------------------------------------------------------------------------------- /MaterialTextField/UIImage+MFTint.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MFTint.h 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 6/08/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | // With thanks to Gordon Fontenot from thoughtbot: 9 | // https://robots.thoughtbot.com/designing-for-ios-blending-modes 10 | // 11 | 12 | #import 13 | 14 | @interface UIImage (MFTint) 15 | 16 | - (UIImage *)mf_tintedImageWithColor:(UIColor *)tintColor; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/eye.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "eye@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "eye@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/lock.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "lock@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "lock@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /MaterialTextField/UIColor+MaterialTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+MaterialTextField.h 3 | // MaterialTextField 4 | // 5 | // Created by Steph Sharp on 22/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (MaterialTextField) 12 | 13 | + (UIColor *)mf_defaultPlaceholderGray; 14 | + (UIColor *)mf_veryDarkGrayColor; 15 | + (UIColor *)mf_darkGrayColor; 16 | + (UIColor *)mf_midGrayColor; 17 | + (UIColor *)mf_lightGrayColor; 18 | + (UIColor *)mf_greenColor; 19 | + (UIColor *)mf_redColor; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MaterialTextField.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MaterialTextField" 3 | s.version = "1.0.1" 4 | s.summary = "Material design UITextField with animated placeholder label and error message" 5 | s.homepage = "https://github.com/stephsharp/MaterialTextField" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = "Stephanie Sharp" 8 | s.platform = :ios, "10.0" 9 | s.source = { :git => "https://github.com/stephsharp/MaterialTextField.git", :tag => "v#{s.version}" } 10 | s.source_files = "MaterialTextField" 11 | s.public_header_files = [ "MaterialTextField/MaterialTextField.h", 12 | "MaterialTextField/MFTextField.h", 13 | "MaterialTextField/UIColor+MaterialTextField.h" ] 14 | s.requires_arc = true 15 | end 16 | -------------------------------------------------------------------------------- /MaterialTextFieldTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MaterialTextField/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.2.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MaterialTextField/UIImage+MFTint.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MFTint.m 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 6/08/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | // With thanks to Gordon Fontenot from thoughtbot: 9 | // https://robots.thoughtbot.com/designing-for-ios-blending-modes 10 | // 11 | 12 | #import "UIImage+MFTint.h" 13 | 14 | @implementation UIImage (MFTint) 15 | 16 | - (UIImage *)mf_tintedImageWithColor:(UIColor *)tintColor 17 | { 18 | UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); 19 | [tintColor setFill]; 20 | CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height); 21 | UIRectFill(bounds); 22 | [self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f]; 23 | 24 | UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext(); 25 | UIGraphicsEndImageContext(); 26 | 27 | return tintedImage; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Stephanie Sharp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MaterialTextFieldTests/MaterialTextFieldTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MaterialTextFieldTests.m 3 | // MaterialTextFieldTests 4 | // 5 | // Created by Adam Sharp on 6/11/2015. 6 | // Copyright © 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MaterialTextFieldTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation MaterialTextFieldTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | // Use XCTAssert and related functions to verify your tests produce the correct results. 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /MaterialTextField/UIColor+MaterialTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+MaterialTextField.m 3 | // MaterialTextField 4 | // 5 | // Created by Steph Sharp on 22/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import "UIColor+MaterialTextField.h" 10 | 11 | @implementation UIColor (MaterialTextField) 12 | 13 | + (UIColor *)colorWithHex:(int)hex 14 | { 15 | return [UIColor colorWithRed:((CGFloat)((hex & 0xFF0000) >> 16)) / 255.0f 16 | green:((CGFloat)((hex & 0x00FF00) >> 8)) / 255.0f 17 | blue:((CGFloat)((hex & 0x0000FF) >> 0)) / 255.0f 18 | alpha:1.0]; 19 | } 20 | 21 | + (UIColor *)mf_defaultPlaceholderGray 22 | { 23 | return [UIColor colorWithRed:0.0f green:0.0f blue:0.098f alpha:0.22f]; 24 | } 25 | 26 | + (UIColor *)mf_veryDarkGrayColor 27 | { 28 | return [UIColor colorWithHex:0x222222]; 29 | } 30 | 31 | + (UIColor *)mf_darkGrayColor 32 | { 33 | return [UIColor colorWithHex:0x666666]; 34 | } 35 | 36 | + (UIColor *)mf_midGrayColor 37 | { 38 | return [UIColor colorWithHex:0x999999]; 39 | } 40 | 41 | + (UIColor *)mf_lightGrayColor 42 | { 43 | return [UIColor colorWithHex:0xBBBBBB]; 44 | } 45 | 46 | + (UIColor *)mf_greenColor 47 | { 48 | return [UIColor colorWithHex:0x29A39C]; 49 | } 50 | 51 | + (UIColor *)mf_redColor 52 | { 53 | return [UIColor colorWithHex:0xED1C29]; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /MaterialTextField/UITextField+MFClearButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+MFClearButton.m 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 11/08/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UITextField+MFClearButton.h" 11 | #import "UIImage+MFTint.h" 12 | 13 | static const void *const MFTintedClearImage = &MFTintedClearImage; 14 | 15 | @interface UITextField () 16 | @property (nonatomic, setter=mf_setTintedClearImage:) UIImage *mf_tintedClearImage; 17 | @end 18 | 19 | @implementation UITextField (MFClearButton) 20 | 21 | - (void)mf_tintClearButton 22 | { 23 | UIButton *clearButton = [self mf_clearButton]; 24 | UIImage *highlightedClearImage = [clearButton imageForState:UIControlStateHighlighted]; 25 | 26 | if (highlightedClearImage) { 27 | if (!self.mf_tintedClearImage) { 28 | self.mf_tintedClearImage = [highlightedClearImage mf_tintedImageWithColor:self.tintColor]; 29 | } 30 | [clearButton setImage:self.mf_tintedClearImage forState:UIControlStateHighlighted]; 31 | } 32 | } 33 | 34 | - (UIButton *)mf_clearButton 35 | { 36 | UIButton *button; 37 | for (UIView *view in self.subviews) { 38 | if ([view isKindOfClass:[UIButton class]]) { 39 | button = (UIButton *)view; 40 | } 41 | } 42 | return button; 43 | } 44 | 45 | - (UIImage *)mf_tintedClearImage 46 | { 47 | return objc_getAssociatedObject(self, MFTintedClearImage); 48 | } 49 | 50 | - (void)mf_setTintedClearImage:(UIImage *)image 51 | { 52 | objc_setAssociatedObject(self, MFTintedClearImage, image, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MaterialTextField 2 | 3 | A [Material Design](https://www.google.com/design/spec/components/text-fields.html#text-fields-single-line-text-field) inspired UITextField with animated placeholder label and error message. 4 | 5 | ![MaterialTextField gif](https://raw.githubusercontent.com/stephsharp/MaterialTextField/master/Screenshots/MaterialTextField.gif) 6 | 7 | ## Features 8 | 9 | ##### Floating placeholder label 10 | 11 | - Animates on focus or on text input 12 | - Supports attributed placeholder text with custom fonts 13 | - Can be turned off to use the text field with the default UITextField placeholder 14 | 15 | ##### Underline 16 | 17 | - Line height expands when editing 18 | - Set colours for default, editing and error states 19 | 20 | ##### Error message 21 | 22 | - Animated error message appears below the text field 23 | - Long error messages wrap onto multiple lines 24 | 25 | 26 | ##### IBDesignable view 27 | 28 | - Adjust the appearance of the text field in Interface Builder with inspectable properties 29 | 30 | ## Setup 31 | 32 | ### CocoaPods 33 | 34 | To install via CocoaPods, add to your podfile: 35 | 36 | pod 'MaterialTextField', '~> 1.0' 37 | 38 | ### Carthage 39 | 40 | First, add this to your Cartfile: 41 | 42 | github "stephsharp/MaterialTextField" 43 | 44 | Then run `carthage update`. 45 | 46 | The recommended way to integrate `MaterialTextField.framework` is as a workspace dependency: 47 | 48 | 1. If you don't yet have a workspace, go to the File menu in Xcode and select Save as Workspace... 49 | 2. At the bottom left of the project navigator, select the + and add `Carthage/Checkouts/MaterialTextField/MaterialTextField.xcodeproj`. 50 | 3. Add `MaterialTextField.framework` to your app's "Link Binary with Libraries" build phase. 51 | 52 | ## Acknowledgements 53 | 54 | I found the following libraries to be useful resources: 55 | 56 | - [MaterialKit](https://github.com/nghialv/MaterialKit) 57 | - [JVFloatLabeledTextField](https://github.com/jverdi/JVFloatLabeledTextField) 58 | 59 | 60 | ## License 61 | 62 | MaterialTextField is released under the MIT license. See LICENSE for details. 63 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MaterialTextField/MFTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // MFTextField.h 3 | // MaterialTextField 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | @interface MFTextField : UITextField 13 | 14 | /** 15 | * textPadding.height: Padding above and below the text field, between the placeholder label and underline. 16 | * textPadding.width: Horizontal padding on the left and right of the text field. 17 | */ 18 | @property (nonatomic) IBInspectable CGSize textPadding; 19 | 20 | /** 21 | * Animate placeholder label above text field on focus or input (see placeholderAnimatesOnFocus). 22 | * Default is YES. 23 | */ 24 | @property (nonatomic) IBInspectable BOOL animatesPlaceholder; 25 | 26 | /** 27 | * Default is NO. If YES, the placeholder label will animate up on focus rather than on text input. 28 | */ 29 | @property (nonatomic) IBInspectable BOOL placeholderAnimatesOnFocus; 30 | 31 | /** 32 | * The color of the text field's default placeholder (displayed when text field is empty). 33 | */ 34 | @property (nonatomic) IBInspectable UIColor *defaultPlaceholderColor; 35 | 36 | /** 37 | * The color of the placeholder label when the text field is not in focus. 38 | */ 39 | @property (nonatomic) IBInspectable UIColor *placeholderColor; 40 | 41 | /** 42 | * Defaults to the first applicable font: 43 | * - the attributed placeholder font at the default placeholder size 44 | * - the text field font at the default placeholder size 45 | */ 46 | @property (nonatomic) UIFont *placeholderFont; 47 | 48 | /** 49 | * The height of the underline when the text field is not in focus. 50 | */ 51 | @property (nonatomic) IBInspectable CGFloat underlineHeight; 52 | 53 | /** 54 | * The height of the underline when the text field is in focus. 55 | */ 56 | @property (nonatomic) IBInspectable CGFloat underlineEditingHeight; 57 | 58 | /** 59 | * The color of the underline when the text field is not in focus. 60 | */ 61 | @property (nonatomic) IBInspectable UIColor *underlineColor; 62 | 63 | /** 64 | * To display an error under the text field, provide an NSError with a localized description. 65 | * 66 | * @param animated Set to YES to animate showing & hiding the error message. 67 | */ 68 | - (void)setError:(NSError *)error animated:(BOOL)animated; 69 | 70 | /** 71 | * The error displayed under the text field. 72 | */ 73 | @property (nonatomic, readonly) NSError *error; 74 | 75 | /** 76 | * The font for the error displayed under the text field. 77 | */ 78 | @property (nonatomic) UIFont *errorFont; 79 | 80 | /** 81 | * The color of the error displayed under the text field. 82 | */ 83 | @property (nonatomic) IBInspectable UIColor *errorColor; 84 | 85 | /** 86 | * errorPadding.height: The vertical padding between the underline and the error label. 87 | * errorPadding.width: Horizontal padding on the left and right of the error label. 88 | */ 89 | @property (nonatomic) IBInspectable CGSize errorPadding; 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo.xcodeproj/xcshareddata/xcschemes/MaterialTextFieldDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MaterialTextField.xcodeproj/xcshareddata/xcschemes/MaterialTextField.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/MaterialTextFieldDemoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MaterialTextFieldDemoViewController.m 3 | // MaterialTextFieldDemo 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MaterialTextFieldDemoViewController.h" 11 | 12 | NSString *const MFDemoErrorDomain = @"MFDemoErrorDomain"; 13 | NSInteger const MFDemoErrorCode = 100; 14 | 15 | @interface MaterialTextFieldDemoViewController () 16 | 17 | @property (weak, nonatomic) IBOutlet MFTextField *textField1; 18 | @property (weak, nonatomic) IBOutlet MFTextField *textField2; 19 | @property (weak, nonatomic) IBOutlet MFTextField *textField4; 20 | @property (weak, nonatomic) IBOutlet MFTextField *textField5; 21 | 22 | @end 23 | 24 | @implementation MaterialTextFieldDemoViewController 25 | 26 | - (void)viewDidLoad 27 | { 28 | [super viewDidLoad]; 29 | 30 | [self setupTextField1]; 31 | [self setupTextField2]; 32 | [self setupTextField4]; 33 | [self setupTextField5]; 34 | } 35 | 36 | #pragma mark - Setup 37 | 38 | - (void)setupTextField1 39 | { 40 | self.textField1.animatesPlaceholder = NO; 41 | self.textField1.tintColor = [UIColor mf_greenColor]; 42 | self.textField1.textColor = [UIColor mf_veryDarkGrayColor]; 43 | } 44 | 45 | - (void)setupTextField2 46 | { 47 | self.textField2.tintColor = [UIColor mf_greenColor]; 48 | self.textField2.textColor = [UIColor mf_veryDarkGrayColor]; 49 | self.textField2.defaultPlaceholderColor = [UIColor mf_darkGrayColor]; 50 | self.textField2.placeholderAnimatesOnFocus = YES; 51 | 52 | UIFontDescriptor * fontDescriptor = [self.textField2.font.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; 53 | UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:self.textField2.font.pointSize]; 54 | 55 | self.textField2.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Attributed placeholder" attributes:@{NSFontAttributeName:font}]; 56 | } 57 | 58 | - (void)setupTextField4 59 | { 60 | UIButton *eyeButton = [UIButton buttonWithType:UIButtonTypeCustom]; 61 | [eyeButton setImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal]; 62 | eyeButton.imageEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0); 63 | eyeButton.bounds = CGRectMake(0, 0, 24, 16); 64 | [eyeButton addTarget:self 65 | action:@selector(togglePassword) 66 | forControlEvents:UIControlEventTouchUpInside]; 67 | 68 | self.textField4.rightViewMode = UITextFieldViewModeAlways; 69 | self.textField4.rightView = eyeButton; 70 | 71 | UIImageView *lockImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lock"]]; 72 | lockImage.bounds = CGRectMake(0, 0, 24, 16); 73 | lockImage.contentMode = UIViewContentModeLeft; 74 | self.textField4.leftViewMode = UITextFieldViewModeAlways; 75 | self.textField4.leftView = lockImage; 76 | } 77 | 78 | - (void)togglePassword 79 | { 80 | self.textField4.secureTextEntry = !self.textField4.isSecureTextEntry; 81 | } 82 | 83 | - (void)setupTextField5 84 | { 85 | [self validateTextField5Animated:NO]; 86 | } 87 | 88 | #pragma mark - Actions 89 | 90 | - (IBAction)dismissKeyboard 91 | { 92 | [self.view endEditing:YES]; 93 | } 94 | 95 | - (IBAction)textFieldDidChange:(UITextField *)textField 96 | { 97 | if (textField == self.textField1) { 98 | [self validateTextField1]; 99 | } 100 | else if (textField == self.textField2) { 101 | [self validateTextField2]; 102 | } 103 | else if (textField == self.textField4) { 104 | [self validateTextField4]; 105 | } 106 | else if (textField == self.textField5) { 107 | [self validateTextField5Animated:YES]; 108 | } 109 | } 110 | 111 | #pragma mark - Text field validation 112 | 113 | - (void)validateTextField1 114 | { 115 | NSError *error = nil; 116 | if (![self textField1IsValid]) { 117 | error = [self errorWithLocalizedDescription:@"Maximum of 6 characters allowed."]; 118 | } 119 | [self.textField1 setError:error animated:YES]; 120 | } 121 | 122 | - (void)validateTextField2 123 | { 124 | NSError *error = nil; 125 | if (![self textField2IsValid]) { 126 | error = [self errorWithLocalizedDescription:@"This is an error message that is really long and should wrap onto 2 or more lines."]; 127 | } 128 | [self.textField2 setError:error animated:YES]; 129 | } 130 | 131 | - (void)validateTextField4 132 | { 133 | NSError *error = nil; 134 | if (![self textField4IsValid]) { 135 | error = [self errorWithLocalizedDescription:@"Password must be less than 16 characters."]; 136 | } 137 | [self.textField4 setError:error animated:YES]; 138 | } 139 | 140 | - (void)validateTextField5Animated:(BOOL)animated 141 | { 142 | NSError *error = nil; 143 | if (![self textField5IsValid]) { 144 | error = [self errorWithLocalizedDescription:@"An error message"]; 145 | } 146 | [self.textField5 setError:error animated:animated]; 147 | } 148 | 149 | - (BOOL)textField1IsValid 150 | { 151 | return self.textField1.text.length <= 6; 152 | } 153 | 154 | - (BOOL)textField2IsValid 155 | { 156 | return self.textField2.text.length < 3; 157 | } 158 | 159 | - (BOOL)textField4IsValid 160 | { 161 | return self.textField4.text.length < 16; 162 | } 163 | 164 | - (BOOL)textField5IsValid 165 | { 166 | return self.textField5.text.length > 0; 167 | } 168 | 169 | - (NSError *)errorWithLocalizedDescription:(NSString *)localizedDescription 170 | { 171 | NSDictionary *userInfo = @{NSLocalizedDescriptionKey: localizedDescription}; 172 | return [NSError errorWithDomain:MFDemoErrorDomain code:MFDemoErrorCode userInfo:userInfo]; 173 | } 174 | 175 | @end 176 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /MaterialTextFieldDemo/MaterialTextFieldDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8229BFD71B5E2A7600C40181 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8229BFD61B5E2A7600C40181 /* main.m */; }; 11 | 8229BFDA1B5E2A7600C40181 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8229BFD91B5E2A7600C40181 /* AppDelegate.m */; }; 12 | 8229BFDD1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8229BFDC1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.m */; }; 13 | 8229BFE01B5E2A7600C40181 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8229BFDE1B5E2A7600C40181 /* Main.storyboard */; }; 14 | 8229BFE21B5E2A7600C40181 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8229BFE11B5E2A7600C40181 /* Images.xcassets */; }; 15 | 8229BFE51B5E2A7600C40181 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8229BFE31B5E2A7600C40181 /* LaunchScreen.xib */; }; 16 | CECEC4381BEBECB500FDD23F /* MaterialTextField.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE4B7E621BEBE94300CD6620 /* MaterialTextField.framework */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 8229BFD11B5E2A7600C40181 /* MaterialTextFieldDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MaterialTextFieldDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 8229BFD51B5E2A7600C40181 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | 8229BFD61B5E2A7600C40181 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 23 | 8229BFD81B5E2A7600C40181 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | 8229BFD91B5E2A7600C40181 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | 8229BFDB1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaterialTextFieldDemoViewController.h; sourceTree = ""; }; 26 | 8229BFDC1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaterialTextFieldDemoViewController.m; sourceTree = ""; }; 27 | 8229BFDF1B5E2A7600C40181 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | 8229BFE11B5E2A7600C40181 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 29 | 8229BFE41B5E2A7600C40181 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 30 | CE4B7E621BEBE94300CD6620 /* MaterialTextField.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MaterialTextField.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 8229BFCE1B5E2A7600C40181 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | CECEC4381BEBECB500FDD23F /* MaterialTextField.framework in Frameworks */, 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 8229BFC81B5E2A7600C40181 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 8229BFD31B5E2A7600C40181 /* MaterialTextFieldDemo */, 49 | CE4B7E611BEBE92B00CD6620 /* Frameworks */, 50 | 8229BFD21B5E2A7600C40181 /* Products */, 51 | ); 52 | indentWidth = 4; 53 | sourceTree = ""; 54 | usesTabs = 0; 55 | }; 56 | 8229BFD21B5E2A7600C40181 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 8229BFD11B5E2A7600C40181 /* MaterialTextFieldDemo.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 8229BFD31B5E2A7600C40181 /* MaterialTextFieldDemo */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 8229BFD81B5E2A7600C40181 /* AppDelegate.h */, 68 | 8229BFD91B5E2A7600C40181 /* AppDelegate.m */, 69 | 8229BFDB1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.h */, 70 | 8229BFDC1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.m */, 71 | 8229BFDE1B5E2A7600C40181 /* Main.storyboard */, 72 | 8229BFE11B5E2A7600C40181 /* Images.xcassets */, 73 | 8229BFE31B5E2A7600C40181 /* LaunchScreen.xib */, 74 | 8229BFD41B5E2A7600C40181 /* Supporting Files */, 75 | ); 76 | path = MaterialTextFieldDemo; 77 | sourceTree = ""; 78 | }; 79 | 8229BFD41B5E2A7600C40181 /* Supporting Files */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 8229BFD51B5E2A7600C40181 /* Info.plist */, 83 | 8229BFD61B5E2A7600C40181 /* main.m */, 84 | ); 85 | name = "Supporting Files"; 86 | sourceTree = ""; 87 | }; 88 | CE4B7E611BEBE92B00CD6620 /* Frameworks */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | CE4B7E621BEBE94300CD6620 /* MaterialTextField.framework */, 92 | ); 93 | name = Frameworks; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXNativeTarget section */ 99 | 8229BFD01B5E2A7600C40181 /* MaterialTextFieldDemo */ = { 100 | isa = PBXNativeTarget; 101 | buildConfigurationList = 8229BFF41B5E2A7600C40181 /* Build configuration list for PBXNativeTarget "MaterialTextFieldDemo" */; 102 | buildPhases = ( 103 | 8229BFCD1B5E2A7600C40181 /* Sources */, 104 | 8229BFCE1B5E2A7600C40181 /* Frameworks */, 105 | 8229BFCF1B5E2A7600C40181 /* Resources */, 106 | ); 107 | buildRules = ( 108 | ); 109 | dependencies = ( 110 | ); 111 | name = MaterialTextFieldDemo; 112 | productName = MaterialTextFieldDemo; 113 | productReference = 8229BFD11B5E2A7600C40181 /* MaterialTextFieldDemo.app */; 114 | productType = "com.apple.product-type.application"; 115 | }; 116 | /* End PBXNativeTarget section */ 117 | 118 | /* Begin PBXProject section */ 119 | 8229BFC91B5E2A7600C40181 /* Project object */ = { 120 | isa = PBXProject; 121 | attributes = { 122 | LastUpgradeCheck = 0930; 123 | ORGANIZATIONNAME = "Stephanie Sharp"; 124 | TargetAttributes = { 125 | 8229BFD01B5E2A7600C40181 = { 126 | CreatedOnToolsVersion = 6.3.2; 127 | }; 128 | }; 129 | }; 130 | buildConfigurationList = 8229BFCC1B5E2A7600C40181 /* Build configuration list for PBXProject "MaterialTextFieldDemo" */; 131 | compatibilityVersion = "Xcode 3.2"; 132 | developmentRegion = English; 133 | hasScannedForEncodings = 0; 134 | knownRegions = ( 135 | en, 136 | Base, 137 | ); 138 | mainGroup = 8229BFC81B5E2A7600C40181; 139 | productRefGroup = 8229BFD21B5E2A7600C40181 /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | 8229BFD01B5E2A7600C40181 /* MaterialTextFieldDemo */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXResourcesBuildPhase section */ 149 | 8229BFCF1B5E2A7600C40181 /* Resources */ = { 150 | isa = PBXResourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | 8229BFE01B5E2A7600C40181 /* Main.storyboard in Resources */, 154 | 8229BFE51B5E2A7600C40181 /* LaunchScreen.xib in Resources */, 155 | 8229BFE21B5E2A7600C40181 /* Images.xcassets in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | 8229BFCD1B5E2A7600C40181 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | 8229BFDD1B5E2A7600C40181 /* MaterialTextFieldDemoViewController.m in Sources */, 167 | 8229BFDA1B5E2A7600C40181 /* AppDelegate.m in Sources */, 168 | 8229BFD71B5E2A7600C40181 /* main.m in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | 8229BFDE1B5E2A7600C40181 /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | 8229BFDF1B5E2A7600C40181 /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | 8229BFE31B5E2A7600C40181 /* LaunchScreen.xib */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | 8229BFE41B5E2A7600C40181 /* Base */, 187 | ); 188 | name = LaunchScreen.xib; 189 | sourceTree = ""; 190 | }; 191 | /* End PBXVariantGroup section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | 8229BFF21B5E2A7600C40181 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 199 | CLANG_CXX_LIBRARY = "libc++"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 203 | CLANG_WARN_BOOL_CONVERSION = YES; 204 | CLANG_WARN_COMMA = YES; 205 | CLANG_WARN_CONSTANT_CONVERSION = YES; 206 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 207 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 208 | CLANG_WARN_EMPTY_BODY = YES; 209 | CLANG_WARN_ENUM_CONVERSION = YES; 210 | CLANG_WARN_INFINITE_RECURSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 217 | CLANG_WARN_STRICT_PROTOTYPES = YES; 218 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 219 | CLANG_WARN_UNREACHABLE_CODE = YES; 220 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 221 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 222 | COPY_PHASE_STRIP = NO; 223 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 224 | ENABLE_STRICT_OBJC_MSGSEND = YES; 225 | ENABLE_TESTABILITY = YES; 226 | GCC_C_LANGUAGE_STANDARD = gnu99; 227 | GCC_DYNAMIC_NO_PIC = NO; 228 | GCC_NO_COMMON_BLOCKS = YES; 229 | GCC_OPTIMIZATION_LEVEL = 0; 230 | GCC_PREPROCESSOR_DEFINITIONS = ( 231 | "DEBUG=1", 232 | "$(inherited)", 233 | ); 234 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 237 | GCC_WARN_UNDECLARED_SELECTOR = YES; 238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 239 | GCC_WARN_UNUSED_FUNCTION = YES; 240 | GCC_WARN_UNUSED_VARIABLE = YES; 241 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 242 | MTL_ENABLE_DEBUG_INFO = YES; 243 | ONLY_ACTIVE_ARCH = YES; 244 | SDKROOT = iphoneos; 245 | TARGETED_DEVICE_FAMILY = "1,2"; 246 | }; 247 | name = Debug; 248 | }; 249 | 8229BFF31B5E2A7600C40181 /* Release */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ALWAYS_SEARCH_USER_PATHS = NO; 253 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 254 | CLANG_CXX_LIBRARY = "libc++"; 255 | CLANG_ENABLE_MODULES = YES; 256 | CLANG_ENABLE_OBJC_ARC = YES; 257 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 258 | CLANG_WARN_BOOL_CONVERSION = YES; 259 | CLANG_WARN_COMMA = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNREACHABLE_CODE = YES; 275 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 276 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 277 | COPY_PHASE_STRIP = NO; 278 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 279 | ENABLE_NS_ASSERTIONS = NO; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu99; 282 | GCC_NO_COMMON_BLOCKS = YES; 283 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 284 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 285 | GCC_WARN_UNDECLARED_SELECTOR = YES; 286 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 287 | GCC_WARN_UNUSED_FUNCTION = YES; 288 | GCC_WARN_UNUSED_VARIABLE = YES; 289 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 290 | MTL_ENABLE_DEBUG_INFO = NO; 291 | SDKROOT = iphoneos; 292 | TARGETED_DEVICE_FAMILY = "1,2"; 293 | VALIDATE_PRODUCT = YES; 294 | }; 295 | name = Release; 296 | }; 297 | 8229BFF51B5E2A7600C40181 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 301 | INFOPLIST_FILE = MaterialTextFieldDemo/Info.plist; 302 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 303 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 304 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME:rfc1034identifier)"; 305 | PRODUCT_NAME = "$(TARGET_NAME)"; 306 | }; 307 | name = Debug; 308 | }; 309 | 8229BFF61B5E2A7600C40181 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | INFOPLIST_FILE = MaterialTextFieldDemo/Info.plist; 314 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 315 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 316 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME:rfc1034identifier)"; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | }; 319 | name = Release; 320 | }; 321 | /* End XCBuildConfiguration section */ 322 | 323 | /* Begin XCConfigurationList section */ 324 | 8229BFCC1B5E2A7600C40181 /* Build configuration list for PBXProject "MaterialTextFieldDemo" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 8229BFF21B5E2A7600C40181 /* Debug */, 328 | 8229BFF31B5E2A7600C40181 /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | 8229BFF41B5E2A7600C40181 /* Build configuration list for PBXNativeTarget "MaterialTextFieldDemo" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | 8229BFF51B5E2A7600C40181 /* Debug */, 337 | 8229BFF61B5E2A7600C40181 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | /* End XCConfigurationList section */ 343 | }; 344 | rootObject = 8229BFC91B5E2A7600C40181 /* Project object */; 345 | } 346 | -------------------------------------------------------------------------------- /MaterialTextField.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* 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 */; }; 12 | CE58F7BD1BEBE64C0082924A /* MaterialTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7BC1BEBE64C0082924A /* MaterialTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | CE58F7C41BEBE64C0082924A /* MaterialTextField.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */; }; 14 | CE58F7C91BEBE64C0082924A /* MaterialTextFieldTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7C81BEBE64C0082924A /* MaterialTextFieldTests.m */; }; 15 | CE58F7DB1BEBE77E0082924A /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7D31BEBE77E0082924A /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | CE58F7DC1BEBE77E0082924A /* MFTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7D41BEBE77E0082924A /* MFTextField.m */; }; 17 | CE58F7DD1BEBE77E0082924A /* UIColor+MaterialTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7D51BEBE77E0082924A /* UIColor+MaterialTextField.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18 | CE58F7DE1BEBE77E0082924A /* UIColor+MaterialTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7D61BEBE77E0082924A /* UIColor+MaterialTextField.m */; }; 19 | CE58F7DF1BEBE77E0082924A /* UIImage+MFTint.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7D71BEBE77E0082924A /* UIImage+MFTint.h */; }; 20 | CE58F7E01BEBE77E0082924A /* UIImage+MFTint.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7D81BEBE77E0082924A /* UIImage+MFTint.m */; }; 21 | CE58F7E11BEBE77E0082924A /* UITextField+MFClearButton.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58F7D91BEBE77E0082924A /* UITextField+MFClearButton.h */; }; 22 | CE58F7E21BEBE77E0082924A /* UITextField+MFClearButton.m in Sources */ = {isa = PBXBuildFile; fileRef = CE58F7DA1BEBE77E0082924A /* UITextField+MFClearButton.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | CE58F7C51BEBE64C0082924A /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = CE58F7B01BEBE64C0082924A /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = CE58F7B81BEBE64C0082924A; 31 | remoteInfo = MaterialTextField; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | 82125D271BEF36E20017F72C /* UIFont+MaterialTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+MaterialTextField.h"; sourceTree = ""; }; 37 | 82125D281BEF36E20017F72C /* UIFont+MaterialTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+MaterialTextField.m"; sourceTree = ""; }; 38 | CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialTextField.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | CE58F7BC1BEBE64C0082924A /* MaterialTextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaterialTextField.h; sourceTree = ""; }; 40 | CE58F7BE1BEBE64C0082924A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | CE58F7C31BEBE64C0082924A /* MaterialTextFieldTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialTextFieldTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | CE58F7C81BEBE64C0082924A /* MaterialTextFieldTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaterialTextFieldTests.m; sourceTree = ""; }; 43 | CE58F7CA1BEBE64C0082924A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | CE58F7D31BEBE77E0082924A /* MFTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextField.h; sourceTree = ""; }; 45 | CE58F7D41BEBE77E0082924A /* MFTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFTextField.m; sourceTree = ""; }; 46 | CE58F7D51BEBE77E0082924A /* UIColor+MaterialTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+MaterialTextField.h"; sourceTree = ""; }; 47 | CE58F7D61BEBE77E0082924A /* UIColor+MaterialTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+MaterialTextField.m"; sourceTree = ""; }; 48 | CE58F7D71BEBE77E0082924A /* UIImage+MFTint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+MFTint.h"; sourceTree = ""; }; 49 | CE58F7D81BEBE77E0082924A /* UIImage+MFTint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+MFTint.m"; sourceTree = ""; }; 50 | CE58F7D91BEBE77E0082924A /* UITextField+MFClearButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITextField+MFClearButton.h"; sourceTree = ""; }; 51 | CE58F7DA1BEBE77E0082924A /* UITextField+MFClearButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextField+MFClearButton.m"; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | CE58F7B51BEBE64C0082924A /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | CE58F7C01BEBE64C0082924A /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | CE58F7C41BEBE64C0082924A /* MaterialTextField.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 82125D251BEEF6010017F72C /* Supporting Files */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | CE58F7BE1BEBE64C0082924A /* Info.plist */, 77 | ); 78 | name = "Supporting Files"; 79 | sourceTree = ""; 80 | }; 81 | 82125D261BEEF6250017F72C /* Supporting Files */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | CE58F7CA1BEBE64C0082924A /* Info.plist */, 85 | ); 86 | name = "Supporting Files"; 87 | sourceTree = ""; 88 | }; 89 | CE58F7AF1BEBE64C0082924A = { 90 | isa = PBXGroup; 91 | children = ( 92 | CE58F7BB1BEBE64C0082924A /* MaterialTextField */, 93 | CE58F7C71BEBE64C0082924A /* MaterialTextFieldTests */, 94 | CE58F7BA1BEBE64C0082924A /* Products */, 95 | ); 96 | indentWidth = 4; 97 | sourceTree = ""; 98 | usesTabs = 0; 99 | }; 100 | CE58F7BA1BEBE64C0082924A /* Products */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */, 104 | CE58F7C31BEBE64C0082924A /* MaterialTextFieldTests.xctest */, 105 | ); 106 | name = Products; 107 | sourceTree = ""; 108 | }; 109 | CE58F7BB1BEBE64C0082924A /* MaterialTextField */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | CE58F7BC1BEBE64C0082924A /* MaterialTextField.h */, 113 | CE58F7D31BEBE77E0082924A /* MFTextField.h */, 114 | CE58F7D41BEBE77E0082924A /* MFTextField.m */, 115 | CE58F7D51BEBE77E0082924A /* UIColor+MaterialTextField.h */, 116 | CE58F7D61BEBE77E0082924A /* UIColor+MaterialTextField.m */, 117 | 82125D271BEF36E20017F72C /* UIFont+MaterialTextField.h */, 118 | 82125D281BEF36E20017F72C /* UIFont+MaterialTextField.m */, 119 | CE58F7D71BEBE77E0082924A /* UIImage+MFTint.h */, 120 | CE58F7D81BEBE77E0082924A /* UIImage+MFTint.m */, 121 | CE58F7D91BEBE77E0082924A /* UITextField+MFClearButton.h */, 122 | CE58F7DA1BEBE77E0082924A /* UITextField+MFClearButton.m */, 123 | 82125D251BEEF6010017F72C /* Supporting Files */, 124 | ); 125 | path = MaterialTextField; 126 | sourceTree = ""; 127 | }; 128 | CE58F7C71BEBE64C0082924A /* MaterialTextFieldTests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | CE58F7C81BEBE64C0082924A /* MaterialTextFieldTests.m */, 132 | 82125D261BEEF6250017F72C /* Supporting Files */, 133 | ); 134 | path = MaterialTextFieldTests; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXHeadersBuildPhase section */ 140 | CE58F7B61BEBE64C0082924A /* Headers */ = { 141 | isa = PBXHeadersBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | CE58F7DF1BEBE77E0082924A /* UIImage+MFTint.h in Headers */, 145 | CE58F7DD1BEBE77E0082924A /* UIColor+MaterialTextField.h in Headers */, 146 | CE58F7E11BEBE77E0082924A /* UITextField+MFClearButton.h in Headers */, 147 | CE58F7BD1BEBE64C0082924A /* MaterialTextField.h in Headers */, 148 | 82125D291BEF36E20017F72C /* UIFont+MaterialTextField.h in Headers */, 149 | CE58F7DB1BEBE77E0082924A /* MFTextField.h in Headers */, 150 | ); 151 | runOnlyForDeploymentPostprocessing = 0; 152 | }; 153 | /* End PBXHeadersBuildPhase section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | CE58F7B81BEBE64C0082924A /* MaterialTextField */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = CE58F7CD1BEBE64C0082924A /* Build configuration list for PBXNativeTarget "MaterialTextField" */; 159 | buildPhases = ( 160 | CE58F7B41BEBE64C0082924A /* Sources */, 161 | CE58F7B51BEBE64C0082924A /* Frameworks */, 162 | CE58F7B61BEBE64C0082924A /* Headers */, 163 | CE58F7B71BEBE64C0082924A /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = MaterialTextField; 170 | productName = MaterialTextField; 171 | productReference = CE58F7B91BEBE64C0082924A /* MaterialTextField.framework */; 172 | productType = "com.apple.product-type.framework"; 173 | }; 174 | CE58F7C21BEBE64C0082924A /* MaterialTextFieldTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = CE58F7D01BEBE64C0082924A /* Build configuration list for PBXNativeTarget "MaterialTextFieldTests" */; 177 | buildPhases = ( 178 | CE58F7BF1BEBE64C0082924A /* Sources */, 179 | CE58F7C01BEBE64C0082924A /* Frameworks */, 180 | CE58F7C11BEBE64C0082924A /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | CE58F7C61BEBE64C0082924A /* PBXTargetDependency */, 186 | ); 187 | name = MaterialTextFieldTests; 188 | productName = MaterialTextFieldTests; 189 | productReference = CE58F7C31BEBE64C0082924A /* MaterialTextFieldTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | CE58F7B01BEBE64C0082924A /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastUpgradeCheck = 0930; 199 | ORGANIZATIONNAME = "Stephanie Sharp"; 200 | TargetAttributes = { 201 | CE58F7B81BEBE64C0082924A = { 202 | CreatedOnToolsVersion = 7.1; 203 | }; 204 | CE58F7C21BEBE64C0082924A = { 205 | CreatedOnToolsVersion = 7.1; 206 | }; 207 | }; 208 | }; 209 | buildConfigurationList = CE58F7B31BEBE64C0082924A /* Build configuration list for PBXProject "MaterialTextField" */; 210 | compatibilityVersion = "Xcode 3.2"; 211 | developmentRegion = English; 212 | hasScannedForEncodings = 0; 213 | knownRegions = ( 214 | en, 215 | ); 216 | mainGroup = CE58F7AF1BEBE64C0082924A; 217 | productRefGroup = CE58F7BA1BEBE64C0082924A /* Products */; 218 | projectDirPath = ""; 219 | projectRoot = ""; 220 | targets = ( 221 | CE58F7B81BEBE64C0082924A /* MaterialTextField */, 222 | CE58F7C21BEBE64C0082924A /* MaterialTextFieldTests */, 223 | ); 224 | }; 225 | /* End PBXProject section */ 226 | 227 | /* Begin PBXResourcesBuildPhase section */ 228 | CE58F7B71BEBE64C0082924A /* Resources */ = { 229 | isa = PBXResourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | CE58F7C11BEBE64C0082924A /* Resources */ = { 236 | isa = PBXResourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXResourcesBuildPhase section */ 243 | 244 | /* Begin PBXSourcesBuildPhase section */ 245 | CE58F7B41BEBE64C0082924A /* Sources */ = { 246 | isa = PBXSourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | CE58F7DC1BEBE77E0082924A /* MFTextField.m in Sources */, 250 | CE58F7DE1BEBE77E0082924A /* UIColor+MaterialTextField.m in Sources */, 251 | CE58F7E21BEBE77E0082924A /* UITextField+MFClearButton.m in Sources */, 252 | CE58F7E01BEBE77E0082924A /* UIImage+MFTint.m in Sources */, 253 | 82125D2A1BEF36E20017F72C /* UIFont+MaterialTextField.m in Sources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | CE58F7BF1BEBE64C0082924A /* Sources */ = { 258 | isa = PBXSourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | CE58F7C91BEBE64C0082924A /* MaterialTextFieldTests.m in Sources */, 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | /* End PBXSourcesBuildPhase section */ 266 | 267 | /* Begin PBXTargetDependency section */ 268 | CE58F7C61BEBE64C0082924A /* PBXTargetDependency */ = { 269 | isa = PBXTargetDependency; 270 | target = CE58F7B81BEBE64C0082924A /* MaterialTextField */; 271 | targetProxy = CE58F7C51BEBE64C0082924A /* PBXContainerItemProxy */; 272 | }; 273 | /* End PBXTargetDependency section */ 274 | 275 | /* Begin XCBuildConfiguration section */ 276 | CE58F7CB1BEBE64C0082924A /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ALWAYS_SEARCH_USER_PATHS = NO; 280 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 281 | CLANG_CXX_LIBRARY = "libc++"; 282 | CLANG_ENABLE_MODULES = YES; 283 | CLANG_ENABLE_OBJC_ARC = YES; 284 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 285 | CLANG_WARN_BOOL_CONVERSION = YES; 286 | CLANG_WARN_COMMA = YES; 287 | CLANG_WARN_CONSTANT_CONVERSION = YES; 288 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 289 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 290 | CLANG_WARN_EMPTY_BODY = YES; 291 | CLANG_WARN_ENUM_CONVERSION = YES; 292 | CLANG_WARN_INFINITE_RECURSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 296 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 297 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 298 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 299 | CLANG_WARN_STRICT_PROTOTYPES = YES; 300 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 301 | CLANG_WARN_UNREACHABLE_CODE = YES; 302 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 303 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 304 | COPY_PHASE_STRIP = NO; 305 | CURRENT_PROJECT_VERSION = 1; 306 | DEBUG_INFORMATION_FORMAT = dwarf; 307 | ENABLE_STRICT_OBJC_MSGSEND = YES; 308 | ENABLE_TESTABILITY = YES; 309 | GCC_C_LANGUAGE_STANDARD = gnu99; 310 | GCC_DYNAMIC_NO_PIC = NO; 311 | GCC_NO_COMMON_BLOCKS = YES; 312 | GCC_OPTIMIZATION_LEVEL = 0; 313 | GCC_PREPROCESSOR_DEFINITIONS = ( 314 | "DEBUG=1", 315 | "$(inherited)", 316 | ); 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 324 | MTL_ENABLE_DEBUG_INFO = YES; 325 | ONLY_ACTIVE_ARCH = YES; 326 | PROJECT_NAME = MaterialTextField; 327 | SDKROOT = iphoneos; 328 | TARGETED_DEVICE_FAMILY = "1,2"; 329 | VERSIONING_SYSTEM = "apple-generic"; 330 | VERSION_INFO_PREFIX = ""; 331 | }; 332 | name = Debug; 333 | }; 334 | CE58F7CC1BEBE64C0082924A /* Release */ = { 335 | isa = XCBuildConfiguration; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 339 | CLANG_CXX_LIBRARY = "libc++"; 340 | CLANG_ENABLE_MODULES = YES; 341 | CLANG_ENABLE_OBJC_ARC = YES; 342 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 343 | CLANG_WARN_BOOL_CONVERSION = YES; 344 | CLANG_WARN_COMMA = YES; 345 | CLANG_WARN_CONSTANT_CONVERSION = YES; 346 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 347 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 348 | CLANG_WARN_EMPTY_BODY = YES; 349 | CLANG_WARN_ENUM_CONVERSION = YES; 350 | CLANG_WARN_INFINITE_RECURSION = YES; 351 | CLANG_WARN_INT_CONVERSION = YES; 352 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 353 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 354 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 356 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 357 | CLANG_WARN_STRICT_PROTOTYPES = YES; 358 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 359 | CLANG_WARN_UNREACHABLE_CODE = YES; 360 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 361 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 362 | COPY_PHASE_STRIP = NO; 363 | CURRENT_PROJECT_VERSION = 1; 364 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 365 | ENABLE_NS_ASSERTIONS = NO; 366 | ENABLE_STRICT_OBJC_MSGSEND = YES; 367 | GCC_C_LANGUAGE_STANDARD = gnu99; 368 | GCC_NO_COMMON_BLOCKS = YES; 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 376 | MTL_ENABLE_DEBUG_INFO = NO; 377 | PROJECT_NAME = MaterialTextField; 378 | SDKROOT = iphoneos; 379 | TARGETED_DEVICE_FAMILY = "1,2"; 380 | VALIDATE_PRODUCT = YES; 381 | VERSIONING_SYSTEM = "apple-generic"; 382 | VERSION_INFO_PREFIX = ""; 383 | }; 384 | name = Release; 385 | }; 386 | CE58F7CE1BEBE64C0082924A /* Debug */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | CODE_SIGN_IDENTITY = ""; 390 | DEFINES_MODULE = YES; 391 | DYLIB_COMPATIBILITY_VERSION = 1; 392 | DYLIB_CURRENT_VERSION = 1; 393 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 394 | INFOPLIST_FILE = MaterialTextField/Info.plist; 395 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 397 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME)"; 398 | PRODUCT_NAME = "$(PROJECT_NAME)"; 399 | SKIP_INSTALL = YES; 400 | }; 401 | name = Debug; 402 | }; 403 | CE58F7CF1BEBE64C0082924A /* Release */ = { 404 | isa = XCBuildConfiguration; 405 | buildSettings = { 406 | CODE_SIGN_IDENTITY = ""; 407 | DEFINES_MODULE = YES; 408 | DYLIB_COMPATIBILITY_VERSION = 1; 409 | DYLIB_CURRENT_VERSION = 1; 410 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 411 | INFOPLIST_FILE = MaterialTextField/Info.plist; 412 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 414 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME)"; 415 | PRODUCT_NAME = "$(PROJECT_NAME)"; 416 | SKIP_INSTALL = YES; 417 | }; 418 | name = Release; 419 | }; 420 | CE58F7D11BEBE64C0082924A /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | INFOPLIST_FILE = MaterialTextFieldTests/Info.plist; 424 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 425 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME)"; 426 | PRODUCT_NAME = "$(PROJECT_NAME)Tests"; 427 | }; 428 | name = Debug; 429 | }; 430 | CE58F7D21BEBE64C0082924A /* Release */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | INFOPLIST_FILE = MaterialTextFieldTests/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 435 | PRODUCT_BUNDLE_IDENTIFIER = "com.ssharp.$(PRODUCT_NAME)"; 436 | PRODUCT_NAME = "$(PROJECT_NAME)Tests"; 437 | }; 438 | name = Release; 439 | }; 440 | /* End XCBuildConfiguration section */ 441 | 442 | /* Begin XCConfigurationList section */ 443 | CE58F7B31BEBE64C0082924A /* Build configuration list for PBXProject "MaterialTextField" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | CE58F7CB1BEBE64C0082924A /* Debug */, 447 | CE58F7CC1BEBE64C0082924A /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | CE58F7CD1BEBE64C0082924A /* Build configuration list for PBXNativeTarget "MaterialTextField" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | CE58F7CE1BEBE64C0082924A /* Debug */, 456 | CE58F7CF1BEBE64C0082924A /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | CE58F7D01BEBE64C0082924A /* Build configuration list for PBXNativeTarget "MaterialTextFieldTests" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | CE58F7D11BEBE64C0082924A /* Debug */, 465 | CE58F7D21BEBE64C0082924A /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | /* End XCConfigurationList section */ 471 | }; 472 | rootObject = CE58F7B01BEBE64C0082924A /* Project object */; 473 | } 474 | -------------------------------------------------------------------------------- /MaterialTextField/MFTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // MFTextField.m 3 | // MaterialTextField 4 | // 5 | // Created by Steph Sharp on 21/07/2015. 6 | // Copyright (c) 2015 Stephanie Sharp. All rights reserved. 7 | // 8 | 9 | #import "MFTextField.h" 10 | #import "UIColor+MaterialTextField.h" 11 | #import "UITextField+MFClearButton.h" 12 | #import "UIFont+MaterialTextField.h" 13 | 14 | static CGFloat const MFDefaultLabelFontSize = 13.0f; 15 | static NSTimeInterval const MFDefaultAnimationDuration = 0.3; 16 | 17 | @interface MFTextField () 18 | 19 | @property (nonatomic) CGRect textRect; 20 | @property (nonatomic) CALayer *underlineLayer; 21 | @property (nonatomic, readonly) BOOL isEmpty; 22 | 23 | @property (nonatomic) UILabel *placeholderLabel; 24 | @property (nonatomic) NSLayoutConstraint *placeholderLabelTopConstraint; 25 | @property (nonatomic) NSArray *placeholderLabelHorizontalConstraints; 26 | @property (nonatomic) NSAttributedString *placeholderAttributedString; 27 | @property (nonatomic) UIFont *defaultPlaceholderFont; 28 | @property (nonatomic, readonly) BOOL shouldShowPlaceholder; 29 | @property (nonatomic, readonly) BOOL placeholderIsHidden; 30 | @property (nonatomic) BOOL placeholderIsAnimating; 31 | 32 | @property (nonatomic) UILabel *errorLabel; 33 | @property (nonatomic) NSLayoutConstraint *errorLabelTopConstraint; 34 | @property (nonatomic) NSLayoutConstraint *errorLabelZeroHeightConstraint; 35 | @property (nonatomic) NSArray *errorLabelHorizontalConstraints; 36 | 37 | @property (nonatomic, readonly) BOOL hasError; 38 | @property (nonatomic) BOOL errorIsAnimating; 39 | 40 | @end 41 | 42 | @implementation MFTextField 43 | 44 | #pragma mark - Initializers 45 | 46 | - (instancetype)initWithFrame:(CGRect)frame 47 | { 48 | self = [super initWithFrame:frame]; 49 | if (self) { 50 | [self sharedInit]; 51 | } 52 | return self; 53 | } 54 | 55 | - (instancetype)initWithCoder:(NSCoder *)coder 56 | { 57 | self = [super initWithCoder:coder]; 58 | if (self) { 59 | [self sharedInit]; 60 | } 61 | return self; 62 | } 63 | 64 | - (void)sharedInit 65 | { 66 | [self setDefaults]; 67 | [self setupTextField]; 68 | [self setupUnderline]; 69 | [self setupErrorLabel]; 70 | } 71 | 72 | #pragma mark - Setup 73 | 74 | - (void)setDefaults 75 | { 76 | self.textPadding = CGSizeMake(0.0f, 8.0f); 77 | self.errorPadding = CGSizeMake(0.0f, 4.0f); 78 | 79 | self.animatesPlaceholder = YES; 80 | self.placeholderColor = [UIColor mf_darkGrayColor]; 81 | self.placeholderFont = self.defaultPlaceholderFont; 82 | 83 | self.underlineHeight = 1.0f; 84 | self.underlineColor = [UIColor mf_lightGrayColor]; 85 | self.underlineEditingHeight = 1.75f; 86 | 87 | self.errorColor = [UIColor mf_redColor]; 88 | self.errorFont = [self defaultErrorFont]; 89 | } 90 | 91 | - (void)setupTextField 92 | { 93 | self.borderStyle = UITextBorderStyleNone; 94 | self.contentVerticalAlignment = UIControlContentVerticalAlignmentTop; 95 | self.clipsToBounds = NO; 96 | } 97 | 98 | - (void)setupUnderline 99 | { 100 | self.underlineLayer = [CALayer layer]; 101 | [self layoutUnderlineLayer]; 102 | [self.layer addSublayer:self.underlineLayer]; 103 | } 104 | 105 | - (void)setupPlaceholderLabel 106 | { 107 | self.placeholderLabel = [UILabel new]; 108 | self.placeholderLabel.translatesAutoresizingMaskIntoConstraints = NO; 109 | self.placeholderLabel.font = self.placeholderFont; 110 | self.placeholderLabel.textAlignment = self.textAlignment; 111 | [self updatePlaceholderText]; 112 | [self updatePlaceholderColor]; 113 | [self addSubview:self.placeholderLabel]; 114 | [self setupPlaceholderConstraints]; 115 | [self layoutPlaceholderLabelAnimated:NO]; 116 | } 117 | 118 | - (void)setupErrorLabel 119 | { 120 | self.errorLabel = [UILabel new]; 121 | self.errorLabel.translatesAutoresizingMaskIntoConstraints = NO; 122 | [self.errorLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; 123 | [self.errorLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; 124 | self.errorLabel.font = self.errorFont; 125 | self.errorLabel.textAlignment = NSTextAlignmentLeft; 126 | self.errorLabel.numberOfLines = 0; 127 | self.errorLabel.textColor = self.errorColor; 128 | [self updateErrorLabelText]; 129 | [self addSubview:self.errorLabel]; 130 | [self setupErrorConstraints]; 131 | [self layoutErrorLabelAnimated:NO]; 132 | } 133 | 134 | - (void)setupPlaceholderConstraints 135 | { 136 | self.placeholderLabelTopConstraint = [self.placeholderLabel.topAnchor constraintEqualToAnchor:self.topAnchor]; 137 | 138 | NSLayoutConstraint *leading = [self.placeholderLabel.leadingAnchor constraintEqualToAnchor:self.leadingAnchor 139 | constant:self.textPadding.width]; 140 | NSLayoutConstraint *trailing = [self.trailingAnchor constraintEqualToAnchor:self.placeholderLabel.trailingAnchor 141 | constant:self.textPadding.width]; 142 | self.placeholderLabelHorizontalConstraints = @[leading, trailing]; 143 | 144 | [NSLayoutConstraint activateConstraints:@[self.placeholderLabelTopConstraint, leading, trailing]]; 145 | } 146 | 147 | - (void)setupErrorConstraints 148 | { 149 | self.errorLabelTopConstraint = [self.errorLabel.topAnchor constraintEqualToAnchor:self.topAnchor 150 | constant:[self topPaddingForErrorLabelHidden:!self.hasError]]; 151 | NSLayoutConstraint *bottom = [self.errorLabel.bottomAnchor constraintEqualToAnchor:self.bottomAnchor]; 152 | NSLayoutConstraint *leading = [self.errorLabel.leadingAnchor constraintEqualToAnchor:self.leadingAnchor 153 | constant:self.errorPadding.width]; 154 | NSLayoutConstraint *trailing = [self.trailingAnchor constraintGreaterThanOrEqualToAnchor:self.errorLabel.trailingAnchor 155 | constant:self.errorPadding.width]; 156 | self.errorLabelHorizontalConstraints = @[leading, trailing]; 157 | 158 | [NSLayoutConstraint activateConstraints:@[self.errorLabelTopConstraint, bottom, leading, trailing]]; 159 | 160 | self.errorLabelZeroHeightConstraint = [self.errorLabel.heightAnchor constraintEqualToConstant:0]; 161 | self.errorLabelZeroHeightConstraint.active = !self.hasError; 162 | } 163 | 164 | #pragma mark - Properties 165 | 166 | #pragma mark Padding 167 | 168 | - (void)setTextPadding:(CGSize)textPadding 169 | { 170 | _textPadding = textPadding; 171 | [self updatePlaceholderHorizontalConstraints]; 172 | } 173 | 174 | - (void)updatePlaceholderHorizontalConstraints 175 | { 176 | for (NSLayoutConstraint *constraint in self.placeholderLabelHorizontalConstraints) { 177 | constraint.constant = self.textPadding.width; 178 | } 179 | } 180 | 181 | - (void)setErrorPadding:(CGSize)errorPadding 182 | { 183 | _errorPadding = errorPadding; 184 | [self updateErrorHorizontalConstraints]; 185 | } 186 | 187 | - (void)updateErrorHorizontalConstraints 188 | { 189 | for (NSLayoutConstraint *constraint in self.errorLabelHorizontalConstraints) { 190 | constraint.constant = self.errorPadding.width; 191 | } 192 | } 193 | 194 | #pragma mark UITextField 195 | 196 | - (void)setFont:(UIFont *)font 197 | { 198 | [super setFont:font]; 199 | [self updateDefaultPlaceholderFont]; 200 | [self updateErrorLabelPosition]; 201 | } 202 | 203 | - (void)setAttributedText:(NSAttributedString *)attributedText 204 | { 205 | [super setAttributedText:attributedText]; 206 | [self updateDefaultPlaceholderFont]; 207 | } 208 | 209 | - (void)setPlaceholder:(NSString *)placeholder 210 | { 211 | [super setPlaceholder:placeholder]; 212 | self.placeholderAttributedString = self.attributedPlaceholder; 213 | [self updatePlaceholderText]; 214 | } 215 | 216 | - (void)setAttributedPlaceholder:(NSAttributedString *)attributedPlaceholder 217 | { 218 | if (self.defaultPlaceholderColor) { 219 | attributedPlaceholder = [self attributedString:attributedPlaceholder withColor:self.defaultPlaceholderColor]; 220 | } 221 | 222 | [super setAttributedPlaceholder:attributedPlaceholder]; 223 | self.placeholderAttributedString = self.attributedPlaceholder; 224 | [self updatePlaceholderText]; 225 | [self updateDefaultPlaceholderFont]; 226 | } 227 | 228 | - (CGRect)textRect 229 | { 230 | _textRect = [self textRectForBounds:self.bounds]; 231 | return _textRect; 232 | } 233 | 234 | #pragma mark Placeholder 235 | 236 | - (void)setAnimatesPlaceholder:(BOOL)animatesPlaceholder 237 | { 238 | _animatesPlaceholder = animatesPlaceholder; 239 | [self removePlaceholderLabel]; 240 | 241 | if (animatesPlaceholder) { 242 | [self setupPlaceholderLabel]; 243 | } 244 | } 245 | 246 | - (void)setDefaultPlaceholderColor:(UIColor *)defaultPlaceholderColor 247 | { 248 | _defaultPlaceholderColor = defaultPlaceholderColor ?: [UIColor mf_defaultPlaceholderGray]; 249 | 250 | if (self.attributedPlaceholder.length > 0) { 251 | self.attributedPlaceholder = [self attributedString:self.attributedPlaceholder withColor:self.defaultPlaceholderColor]; 252 | } 253 | } 254 | 255 | - (void)setPlaceholderColor:(UIColor *)placeholderColor 256 | { 257 | _placeholderColor = placeholderColor; 258 | [self updatePlaceholderColor]; 259 | } 260 | 261 | - (void)setPlaceholderFont:(UIFont *)placeholderFont 262 | { 263 | _placeholderFont = placeholderFont ?: self.defaultPlaceholderFont; 264 | self.placeholderLabel.font = _placeholderFont; 265 | [self updatePlaceholderText]; 266 | } 267 | 268 | - (UIFont *)defaultPlaceholderFont 269 | { 270 | if (!_defaultPlaceholderFont) { 271 | _defaultPlaceholderFont = [self defaultFontForPlaceholder]; 272 | } 273 | return _defaultPlaceholderFont; 274 | } 275 | 276 | #pragma mark Error 277 | 278 | - (void)setError:(NSError *)error animated:(BOOL)animated 279 | { 280 | _error = error; 281 | [self layoutErrorLabelAnimated:animated]; 282 | } 283 | 284 | - (void)setErrorColor:(UIColor *)errorColor 285 | { 286 | _errorColor = errorColor; 287 | self.errorLabel.textColor = errorColor; 288 | } 289 | 290 | - (void)setErrorFont:(UIFont *)errorFont 291 | { 292 | _errorFont = errorFont; 293 | self.errorLabel.font = errorFont; 294 | } 295 | 296 | #pragma mark Computed 297 | 298 | - (BOOL)shouldShowPlaceholder 299 | { 300 | BOOL isEmpty = self.text.length == 0; 301 | 302 | return !isEmpty || (self.placeholderAnimatesOnFocus && self.isFirstResponder); 303 | } 304 | 305 | - (BOOL)hasError 306 | { 307 | return self.error.localizedDescription.length > 0; 308 | } 309 | 310 | - (BOOL)placeholderIsHidden 311 | { 312 | return self.placeholderLabel.alpha == 0.0f; 313 | } 314 | 315 | #pragma mark - Layout 316 | 317 | - (void)layoutSubviews 318 | { 319 | [super layoutSubviews]; 320 | 321 | [self layoutUnderlineLayer]; 322 | [self mf_tintClearButton]; 323 | 324 | if (self.animatesPlaceholder) { 325 | [self layoutPlaceholderLabelAnimated:YES]; 326 | } 327 | } 328 | 329 | - (void)layoutUnderlineLayer 330 | { 331 | [self updateUnderlineColor]; 332 | [self updateUnderlineFrame]; 333 | } 334 | 335 | - (void)layoutPlaceholderLabelAnimated:(BOOL)animated 336 | { 337 | if (self.shouldShowPlaceholder) { 338 | [self updatePlaceholderColor]; 339 | [self showPlaceholderLabelAnimated:animated]; 340 | } 341 | else { 342 | [self hidePlaceholderLabelAnimated:animated]; 343 | } 344 | } 345 | 346 | - (void)layoutErrorLabelAnimated:(BOOL)animated 347 | { 348 | if (self.hasError) { 349 | [self showErrorLabelAnimated:animated]; 350 | } 351 | else { 352 | [self hideErrorLabelAnimated:animated]; 353 | } 354 | } 355 | 356 | #pragma mark - Underline 357 | 358 | - (void)updateUnderlineColor 359 | { 360 | UIColor *underlineColor; 361 | 362 | if (self.hasError) { 363 | underlineColor = self.errorColor; 364 | } 365 | else { 366 | underlineColor = self.isFirstResponder ? self.tintColor : self.underlineColor; 367 | } 368 | 369 | self.underlineLayer.backgroundColor = underlineColor.CGColor; 370 | } 371 | 372 | - (void)updateUnderlineFrame 373 | { 374 | CGFloat underlineHeight = self.isFirstResponder ? self.underlineEditingHeight : self.underlineHeight; 375 | CGFloat yPos = CGRectGetMaxY(self.textRect) + self.textPadding.height - underlineHeight; 376 | 377 | self.underlineLayer.frame = CGRectMake(0, yPos, CGRectGetWidth(self.bounds), underlineHeight); 378 | 379 | if (!self.errorIsAnimating) { 380 | [self updateErrorLabelPosition]; 381 | } 382 | } 383 | 384 | #pragma mark - Placeholder 385 | 386 | - (UIFont *)defaultFontForPlaceholder 387 | { 388 | UIFont *font; 389 | 390 | if (self.attributedPlaceholder.length > 0) { 391 | font = [self.attributedPlaceholder attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; 392 | } 393 | else if (self.placeholderAttributedString.length > 0) { 394 | font = [self.placeholderAttributedString attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; 395 | } 396 | else if (self.attributedText.length > 0) { 397 | font = [self.attributedText attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; 398 | } 399 | else { 400 | font = self.font; 401 | } 402 | 403 | return [UIFont fontWithName:font.fontName size:MFDefaultLabelFontSize]; 404 | } 405 | 406 | - (void)updateDefaultPlaceholderFont 407 | { 408 | BOOL isUsingDefaultFont = [self.placeholderFont isEqual:self.defaultPlaceholderFont]; 409 | 410 | self.defaultPlaceholderFont = [self defaultFontForPlaceholder]; 411 | 412 | if (!self.defaultPlaceholderFont || isUsingDefaultFont) { 413 | self.placeholderFont = self.defaultPlaceholderFont; 414 | } 415 | } 416 | 417 | - (void)showPlaceholderLabelAnimated:(BOOL)animated 418 | { 419 | if (self.placeholderAnimatesOnFocus) { 420 | // Call setPlaceholder on super so placeholderAttributedString is not set to nil 421 | [super setPlaceholder:nil]; 422 | } 423 | 424 | if (!self.placeholderIsHidden) { 425 | return; 426 | } 427 | 428 | if (animated && !self.placeholderIsAnimating) { 429 | [self.superview layoutIfNeeded]; 430 | 431 | self.placeholderIsAnimating = YES; 432 | self.placeholderLabelTopConstraint.constant = 0; 433 | 434 | [UIView animateWithDuration:MFDefaultAnimationDuration 435 | delay:0.0 436 | options:UIViewAnimationOptionCurveEaseOut 437 | animations:^{ 438 | self.placeholderLabel.alpha = 1.0f; 439 | [self.superview layoutIfNeeded]; 440 | } completion:^(BOOL finished) { 441 | self.placeholderIsAnimating = NO; 442 | // Layout label without animation if state has changed since animation started. 443 | if (!self.shouldShowPlaceholder) { 444 | [self hidePlaceholderLabelAnimated:NO]; 445 | } 446 | }]; 447 | } 448 | else if (!animated) { 449 | self.placeholderLabel.alpha = 1.0f; 450 | self.placeholderLabelTopConstraint.constant = 0; 451 | } 452 | } 453 | 454 | - (void)hidePlaceholderLabelAnimated:(BOOL)animated 455 | { 456 | if (self.placeholderIsHidden) { 457 | return; 458 | } 459 | 460 | CGFloat finalDistanceFromTop = CGRectGetMinY(self.textRect) / 2.0f; 461 | 462 | if (self.placeholderAnimatesOnFocus) { 463 | self.attributedPlaceholder = self.placeholderAttributedString; 464 | } 465 | 466 | if (animated && !self.placeholderIsAnimating) { 467 | [self.superview layoutIfNeeded]; 468 | 469 | self.placeholderIsAnimating = YES; 470 | self.placeholderLabelTopConstraint.constant = finalDistanceFromTop; 471 | 472 | [UIView animateWithDuration:MFDefaultAnimationDuration * 0.3 473 | delay:0.0 474 | options:UIViewAnimationOptionCurveEaseOut 475 | animations:^{ 476 | self.placeholderLabel.alpha = 0.0f; 477 | [self.superview layoutIfNeeded]; 478 | } completion:^(BOOL finished) { 479 | self.placeholderIsAnimating = NO; 480 | // Layout label without animation if state has changed since animation started. 481 | if (self.shouldShowPlaceholder) { 482 | [self showPlaceholderLabelAnimated:NO]; 483 | } 484 | }]; 485 | } 486 | else if (!animated) { 487 | self.placeholderLabel.alpha = 0.0f; 488 | self.placeholderLabelTopConstraint.constant = finalDistanceFromTop; 489 | } 490 | } 491 | 492 | - (void)updatePlaceholderText 493 | { 494 | self.placeholderLabel.text = self.placeholder ?: self.placeholderAttributedString.string; 495 | [self.placeholderLabel sizeToFit]; 496 | [self invalidateIntrinsicContentSize]; 497 | } 498 | 499 | - (void)updatePlaceholderColor 500 | { 501 | UIColor *color; 502 | 503 | if (self.isFirstResponder) { 504 | color = (self.hasError) ? self.errorColor : self.tintColor; 505 | } 506 | else { 507 | color = self.placeholderColor; 508 | } 509 | 510 | self.placeholderLabel.textColor = color; 511 | } 512 | 513 | - (NSAttributedString *)attributedString:(NSAttributedString *)attributedString withColor:(UIColor *)color 514 | { 515 | NSMutableDictionary *attributes; 516 | 517 | if (attributedString.length > 0) { 518 | attributes = [[attributedString attributesAtIndex:0 effectiveRange:NULL] mutableCopy]; 519 | } 520 | else { 521 | attributes = [NSMutableDictionary dictionary]; 522 | } 523 | attributes[NSForegroundColorAttributeName] = color; 524 | 525 | return [[NSAttributedString alloc] initWithString:attributedString.string ?: @"" 526 | attributes:attributes]; 527 | } 528 | 529 | - (void)removePlaceholderLabel 530 | { 531 | if (self.placeholderLabel) { 532 | [self.placeholderLabel removeFromSuperview]; 533 | self.placeholderLabel = nil; 534 | } 535 | } 536 | 537 | #pragma mark - Error message 538 | 539 | - (UIFont *)defaultErrorFont 540 | { 541 | return [self.font fontWithSize:MFDefaultLabelFontSize]; 542 | } 543 | 544 | - (void)showErrorLabelAnimated:(BOOL)animated 545 | { 546 | [self updateErrorLabelText]; 547 | 548 | if (animated && !self.errorIsAnimating) { 549 | [self.superview layoutIfNeeded]; 550 | 551 | self.errorIsAnimating = YES; 552 | self.errorLabelZeroHeightConstraint.active = NO; 553 | self.errorLabelTopConstraint.constant = [self topPaddingForErrorLabelHidden:NO]; 554 | 555 | [UIView animateWithDuration:MFDefaultAnimationDuration 556 | delay:0.0 557 | options:UIViewAnimationOptionCurveEaseInOut 558 | animations:^{ 559 | [self.superview layoutIfNeeded]; 560 | self.errorLabel.alpha = 1.0f; 561 | } completion:^(BOOL finished) { 562 | self.errorIsAnimating = NO; 563 | // Layout error label without animation if isValid has changed since animation started. 564 | if (!self.hasError) { 565 | [self hideErrorLabelAnimated:NO]; 566 | } 567 | }]; 568 | } 569 | else if (!animated) { 570 | self.errorLabel.alpha = 1.0f; 571 | self.errorLabelTopConstraint.constant = [self topPaddingForErrorLabelHidden:NO]; 572 | self.errorLabelZeroHeightConstraint.active = NO; 573 | } 574 | } 575 | 576 | - (void)hideErrorLabelAnimated:(BOOL)animated 577 | { 578 | if (animated && !self.errorIsAnimating) { 579 | self.errorIsAnimating = YES; 580 | [UIView animateWithDuration:MFDefaultAnimationDuration * 0.5 581 | delay:0.0 582 | options:UIViewAnimationOptionCurveEaseOut 583 | animations:^{ 584 | self.errorLabel.alpha = 0.0f; 585 | } completion:^(BOOL finished) { 586 | [self.superview layoutIfNeeded]; 587 | 588 | self.errorLabelTopConstraint.constant = [self topPaddingForErrorLabelHidden:YES]; 589 | self.errorLabelZeroHeightConstraint.active = YES; 590 | 591 | [UIView animateWithDuration:MFDefaultAnimationDuration * 0.3 592 | delay:0.0 593 | options:UIViewAnimationOptionCurveEaseOut 594 | animations:^{ 595 | [self.superview layoutIfNeeded]; 596 | } completion:^(BOOL finished) { 597 | self.errorIsAnimating = NO; 598 | [self updateErrorLabelText]; 599 | // Layout error label without animation if isValid has changed since animation started. 600 | if (self.hasError) { 601 | [self showErrorLabelAnimated:NO]; 602 | } 603 | }]; 604 | }]; 605 | } 606 | else if (!animated) { 607 | self.errorLabel.alpha = 0.0f; 608 | self.errorLabelTopConstraint.constant = [self topPaddingForErrorLabelHidden:YES]; 609 | self.errorLabelZeroHeightConstraint.active = YES; 610 | } 611 | } 612 | 613 | - (void)updateErrorLabelText 614 | { 615 | self.errorLabel.text = self.error.localizedDescription; 616 | [self.errorLabel sizeToFit]; 617 | } 618 | 619 | - (CGFloat)topPaddingForErrorLabelHidden:(BOOL)hidden 620 | { 621 | CGFloat topPadding = CGRectGetMaxY(self.underlineLayer.frame); 622 | 623 | if (!hidden) { 624 | topPadding += self.errorPadding.height; 625 | } 626 | 627 | return topPadding; 628 | } 629 | 630 | - (void)updateErrorLabelPosition 631 | { 632 | self.errorLabelTopConstraint.constant = [self topPaddingForErrorLabelHidden:!self.hasError]; 633 | } 634 | 635 | - (void)removeErrorLabel 636 | { 637 | if (self.errorLabel) { 638 | [self.errorLabel removeFromSuperview]; 639 | self.errorLabel = nil; 640 | } 641 | } 642 | 643 | #pragma mark - UITextField 644 | 645 | - (CGRect)textRectForBounds:(CGRect)bounds 646 | { 647 | CGRect superRect = [super textRectForBounds:bounds]; 648 | CGRect rightRect = [super rightViewRectForBounds:bounds]; 649 | BOOL hasLeftView = [self leftViewRectForBounds:bounds].size.width > 0; 650 | BOOL hasRightView = [self rightViewRectForBounds:bounds].size.width > 0; 651 | 652 | CGFloat leftPadding = hasLeftView ? 0 : self.textPadding.width; 653 | CGFloat rightPadding = hasRightView ? rightRect.size.width : self.textPadding.width * 2; 654 | 655 | CGRect rect = CGRectMake(superRect.origin.x + leftPadding, 656 | [self adjustedYPositionForTextRect], 657 | superRect.size.width - rightPadding, 658 | self.font.lineHeight); 659 | self.textRect = rect; 660 | return rect; 661 | } 662 | 663 | - (CGFloat)adjustedYPositionForTextRect 664 | { 665 | CGFloat top = ceil(self.textPadding.height); 666 | if (self.animatesPlaceholder) { 667 | top += self.placeholderFont.lineHeight; 668 | } 669 | return top; 670 | } 671 | 672 | - (CGRect)editingRectForBounds:(CGRect)bounds 673 | { 674 | return [self textRectForBounds:bounds]; 675 | } 676 | 677 | - (CGRect)placeholderRectForBounds:(CGRect)bounds 678 | { 679 | return [self textRectForBounds:bounds]; 680 | } 681 | 682 | - (CGRect)clearButtonRectForBounds:(CGRect)bounds 683 | { 684 | CGRect clearButtonRect = [super clearButtonRectForBounds:bounds]; 685 | clearButtonRect.origin.y = CGRectGetMidY(_textRect) - (clearButtonRect.size.height / 2.0f); 686 | 687 | return clearButtonRect; 688 | } 689 | 690 | - (CGRect)rightViewRectForBounds:(CGRect)bounds 691 | { 692 | CGRect rightViewRect = [super rightViewRectForBounds:bounds]; 693 | rightViewRect.origin.x = rightViewRect.origin.x - self.textPadding.width; 694 | rightViewRect.origin.y = CGRectGetMidY(_textRect) - (rightViewRect.size.height / 2.0f); 695 | 696 | return rightViewRect; 697 | } 698 | 699 | - (CGRect)leftViewRectForBounds:(CGRect)bounds 700 | { 701 | CGRect leftViewRect = [super leftViewRectForBounds:bounds]; 702 | leftViewRect.origin.x = self.textPadding.width; 703 | leftViewRect.origin.y = CGRectGetMidY(_textRect) - (leftViewRect.size.height / 2.0f); 704 | 705 | return leftViewRect; 706 | } 707 | 708 | # pragma mark - UIView 709 | 710 | - (CGSize)intrinsicContentSize 711 | { 712 | CGSize intrinsicSize = [super intrinsicContentSize]; 713 | 714 | if (!self.hasError) { 715 | intrinsicSize.height = CGRectGetMaxY(self.underlineLayer.frame); 716 | } 717 | 718 | return intrinsicSize; 719 | } 720 | 721 | #pragma mark - Interface builder 722 | 723 | - (void)prepareForInterfaceBuilder 724 | { 725 | [self setDefaults]; 726 | [self setupTextField]; 727 | [self setupUnderline]; 728 | 729 | self.animatesPlaceholder = NO; 730 | [self.errorLabel removeFromSuperview]; 731 | } 732 | 733 | @end 734 | --------------------------------------------------------------------------------