Giter VIP home page Giter VIP logo

lunfield's Introduction

LUNField

Foo

This project aims to provide simple customizable nice textfield with grouping.

Please check this article on our blog.

Purpose

LUNField is class designed to simplify the implementation of textfield's group with nice animation. It includes possibillity to validate content to pay user's attention. Also you can use it as normal textfield, but with moving placeholder and nice border animation. For example, you can use it as input element for credit-cards numbers or mobile phones.

Supported OS & SDK Versions

  • Supported build target - iOS 8.0

ARC Compatibility

LUNField requires ARC.

Thread Safety

LUNField is derived from UIView and - as with all UIKit components - it should only be accessed from the main thread.

Examples

Basic usage:

1_video.gif

Highlighting correct input:

2_video.gif

Installation

To use the LUNField class in an app, just drag the LUNField class files (demo files and assets are not needed) into your project.

Also you can use CocoaPods

Сocoapods version

pod 'LUNField'

Properties

@property (weak, nonatomic) IBOutlet id <LUNFieldDataSource> dataSource;

An object that supports the LUNFieldDataSource protocol and provide possibility to construct and modify LUNField.

@property (weak, nonatomic) IBOutlet id <LUNFieldDelegate> delegate;

An object that supports the LUNFieldDelegate protocol and can respond to LUNField events.

@property (strong, nonatomic) NSString *text;

The text displayed by the text field.

@property (assign, nonatomic) UIKeyboardType keyboardType;

The keyboard style associated with the text object.

@property (strong, nonatomic) UIFont *placeholderFont;

@property (strong, nonatomic) IBInspectable NSString *placeholderText;

@property (strong, nonatomic) IBInspectable UIColor *placeholderFontColor;

@property (strong, nonatomic) IBInspectable UIColor *upperPlaceholderFontColor;

@property (strong, nonatomic) IBInspectable UIImage *placeholderImage;

These properties customize placeholder of LUNField.

@property (strong, nonatomic) UIFont *textFont;

@property (strong, nonatomic) IBInspectable UIColor *textFontColor;

@property (strong, nonatomic) IBInspectable UIColor *tintColor;

These properties customize text in LUNField.

@property (assign, nonatomic) IBInspectable CGFloat borderWidth;

@property (strong, nonatomic) IBInspectable UIColor *borderColor;

@property (strong, nonatomic) IBInspectable UIColor *upperBorderColor;

These properties customize borders in LUNField.

@property (strong, nonatomic) IBInspectable UIColor *underliningColor;

If borderColor is nil, this property customizes underlining in LUNField.

@property (strong, nonatomic) IBInspectable NSString *correctLabelText;

@property (strong, nonatomic) IBInspectable UIColor *correctStateBorderColor;

@property (strong, nonatomic) IBInspectable UIColor *correctStatePlaceholderLabelTextColor;

@property (strong, nonatomic) IBInspectable UIImage *correctStateImage;

These properties customize state of LUNField after successful validation.

@property (strong, nonatomic) IBInspectable NSString *incorrectLabelText;

@property (strong, nonatomic) IBInspectable UIColor *incorrectStateBorderColor;

@property (strong, nonatomic) IBInspectable UIColor *incorrectStatePlaceholderLabelTextColor;

@property (strong, nonatomic) IBInspectable UIImage *incorrectStateImage;

These properties customize state of LUNField after failed validation.

@property (strong, nonatomic) UIView *leftView;

This property is similar to textfield’s leftView. It affects LUNField only when numberOfSections in LUNField is equal to 1.

@property (strong, nonatomic) UIView *accessoryView;

This property is similar to textfield’s inputAccessoryView.

@property (assign, nonatomic, readonly) LUNValidationOfContent isCorrect;

This property contains validation result.

@property (assign, nonatomic) LUNAccessoryViewMode accessoryViewMode;

This property is responsible for showing accessoryView. Defines would it be shown at each section or only at last section.

@property (assign, nonatomic) LUNPlaceholderAlignment placeholderAlignment;

This property defines placeholder label’s alignment in LUNField.

Methods

The LUNField class has the following methods:

- (BOOL)isFirstResponder;

Returns a Boolean value indicating whether the LUNField is the first responder.

- (void)becomeFirstResponder;

LUNField’s first unfilled text field becomes first responder.

- (void)resignFirstResponder;

LUNField’s textfields resign first responder.

- (void)reload;

This reloads LUNField from the dataSource and refreshes the display. Doesn’t affect text.

Also LUNField has several fabric methods that helps customize LUNField with default templates:

+ (LUNField *)LUNBorderedFieldWithDataSource:(id<LUNFieldDataSource>)dataSource delegate:(id<LUNFieldDelegate>)delegate;

+ (LUNField *)LUNUnderlinedFieldWithDataSource:(id<LUNFieldDataSource>)dataSource delegate:(id<LUNFieldDelegate>)delegate;

+ (LUNField *)LUNBorderedFieldWithWithDataSource:(id<LUNFieldDataSource> )dataSource delegate:(id<LUNFieldDelegate>)delegate placeholderText:(NSString *)placeholderText;

+ (LUNField *)LUNBorderedFieldWithDataSource:(id<LUNFieldDataSource>)dataSource delegate:(id<LUNFieldDelegate>)delegate placeholderText:(NSString *)placeholderText borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor upperBorderColor:(UIColor *)upperBorderColor;

+ (LUNField *)LUNUnderlinedFieldWithDataSource:(id<LUNFieldDataSource>)dataSource delegate:(id<LUNFieldDelegate>)delegate underliningHeight:(CGFloat)underliningHeight underliningColor:(UIColor *)underliningColor;

Protocols

The LUNField follows the Apple convention for data-driven views by providing two protocol interfaces, LUNFieldDataSource and LUNFieldDelegate.

LUNFieldDataSource

The LUNFieldDataSource protocol has the following required methods:

- (NSUInteger)numberOfSectionsInTextField:(LUNField *)LUNField;

Returns the number of sections (UITextFields) in LUNField.

- (NSUInteger)numberOfCharactersInSection:(NSInteger)section inTextField:(LUNField *)LUNField;

Returns maximum number of symbols in requested section in LUNField. LUNField’s sections are constructed proportionally to this numbers.

LUNFieldDelegate

The LUNFieldDelegate protocol has the following optional methods:

- (void)LUNFieldTextChanged:(LUNField *)LUNField;

Notifies that text in LUNField has been changed.

- (void)LUNFieldHasEndedEditing:(LUNField *)LUNField;

Notifies that LUNField has ended editing.

- (BOOL)LUNField:(LUNField *)LUNField containsValidText:(NSString *)text;

Asks if the text in LUNField is valid; called when LUNField ended editing.

License

Usage is provided under the MIT License

lunfield's People

Contributors

fortuneless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lunfield's Issues

Interface Builder crash

Hello,
layoutIfNeeded inside layoutSubviews cause a IB crash :

Process:               IBDesignablesAgentCocoaTouch [10402]
Path:                  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/IBDesignablesAgentCocoaTouch
Identifier:            IBDesignablesAgentCocoaTouch
Version:               8.3.3 (12089)
Code Type:             X86-64 (Native)
Parent Process:        launchd_sim [9099]
Responsible:           IBDesignablesAgentCocoaTouch [10402]
User ID:               501

Date/Time:             2017-09-17 20:54:19.913 +0200
OS Version:            Mac OS X 10.12.6 (16G29)
Report Version:        12
Anonymous UUID:        93CD3DD9-5B46-47DE-A6CA-91E31D2A575E


Time Awake Since Boot: 6400 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x00007fff50e94ff8
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x7fff50e94ff8:
    MALLOC_TINY            00007f9dce800000-00007f9dcea00000 [ 2048K] rw-/rwx SM=PRV  
--> STACK GUARD            00007fff4d695000-00007fff50e95000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
    Stack                  00007fff50e95000-00007fff51695000 [ 8192K] rw-/rwx SM=COW  thread 0

Application Specific Information:
CoreSimulator 375.21 - Device: IBSimDeviceTypeiPad2x - Runtime: iOS 10.3 (14E8301) - DeviceType: IBSimDeviceTypeiPad2x

Thread 0 Crashed:
0   com.apple.QuartzCore          	0x0000000111285e10 CA::Transaction::ensure_compat() + 4
1   com.apple.QuartzCore          	0x00000001112cf324 -[CALayer actionForKey:] + 29
2   com.apple.QuartzCore          	0x00000001112caade actionForKey(CALayer*, CA::Transaction*, NSString*) + 76
3   com.apple.QuartzCore          	0x00000001112caa6c CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*&) + 140
4   com.apple.QuartzCore          	0x00000001112cbdad CA::Layer::set_bounds(CA::Rect const&, bool) + 329
5   com.apple.QuartzCore          	0x00000001112cbfe0 -[CALayer setBounds:] + 156
6   com.apple.UIKit               	0x000000010ecc305f __27-[_UILabelLayer setBounds:]_block_invoke + 80
7   com.apple.UIKit               	0x000000010ecc2da1 -[_UILabelLayer _setFrameOrBounds:settingAction:] + 23
8   com.apple.UIKit               	0x000000010ecc2ffe -[_UILabelLayer setBounds:] + 155
9   com.apple.UIKit               	0x000000010e77a51b -[UIView(Geometry) setBounds:] + 560
10  com.apple.UIKit               	0x000000010e9560c9 -[UILabel setBounds:] + 144
11  com.apple.UIKit               	0x000000010e779e73 -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 598
12  com.apple.UIKit               	0x000000010e77a15e -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 125
13  com.apple.CoreFoundation      	0x00000001125f4652 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
14  com.apple.CoreFoundation      	0x00000001125f456f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 335
15  com.apple.UIKit               	0x000000010e778bcc -[UIView(Geometry) resizeSubviewsWithOldSize:] + 183
16  com.apple.UIKit               	0x000000010f09516d -[UIView(AdditionalLayoutSupport) _is_layout] + 168
17  com.apple.UIKit               	0x000000010e7850a6 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 994
18  org.cocoapods.LUNField        	0x000000011d4970c9 -[LUNField layoutSubviews] + 89 (LUNField.m:138)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.