├── .gitignore ├── .travis.yml ├── LEAmountInputView.podspec ├── LEAmountInputView ├── LEAmountInputTextField.h ├── LEAmountInputTextField.m ├── LEAmountInputView.h ├── LEAmountInputView.m ├── LENumberPad.h ├── LENumberPad.m ├── LENumberPadCollectionViewCell.h ├── LENumberPadCollectionViewCell.m ├── NSNumberFormatter+LEAmountInputView.h ├── NSNumberFormatter+LEAmountInputView.m ├── UIImage+LENumberPad.h └── UIImage+LENumberPad.m ├── LEAmountInputViewDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── LEAmountInputViewDemo.xcscheme ├── LEAmountInputViewDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── README.md └── Screenshots └── example.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | script: xctool -project LEAmountInputViewDemo.xcodeproj -scheme LEAmountInputViewDemo -sdk iphonesimulator8.1 3 | -------------------------------------------------------------------------------- /LEAmountInputView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint LEAmountInputView.podspec' to ensure this is a 3 | # valid spec and remove all comments before submitting the spec. 4 | # 5 | # Any lines starting with a # are optional, but encouraged 6 | # 7 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 8 | # 9 | 10 | Pod::Spec.new do |s| 11 | s.name = "LEAmountInputView" 12 | s.version = "0.1.6" 13 | s.summary = "Amount Input View (inspired by Square's design)" 14 | s.description = "LEAmountInputView is an amount input view inspired by Square's design" 15 | s.homepage = "https://github.com/efremidze/LEAmountInputView" 16 | s.screenshots = "https://github.com/efremidze/LEAmountInputView/raw/master/Screenshots/example.gif" 17 | s.license = 'MIT' 18 | s.author = { "Lasha Efremidze" => "efremidzel@hotmail.com" } 19 | s.source = { :git => "https://github.com/efremidze/LEAmountInputView.git", :tag => s.version.to_s } 20 | s.social_media_url = 'http://linkedin.com/in/efremidze' 21 | s.platform = :ios, '7.0' 22 | s.requires_arc = true 23 | s.source_files = 'LEAmountInputView/*.{h,m}' 24 | end 25 | -------------------------------------------------------------------------------- /LEAmountInputView/LEAmountInputTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // LEAmountInputTextField.h 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 6/10/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "LENumberPad.h" 12 | 13 | @class LEAmountInputTextField; 14 | 15 | /** 16 | * The LEAmountInputTextFieldDelegate protocol defines the amount messages sent to a text field delegate. All of the methods of this protocol are optional. 17 | * 18 | * Inherits from UITextFieldDelegate. 19 | */ 20 | @protocol LEAmountInputTextFieldDelegate 21 | 22 | @optional 23 | 24 | /** 25 | * Asks the delegate whether the amount should be changed. 26 | * 27 | * If you do not implement this method, the default return value is YES. 28 | * 29 | * @param textField The text field object that is asking whether the amount should change. 30 | * @param amount The new amount. 31 | * 32 | * @return YES if the amount should be changed or NO if it should not. 33 | */ 34 | - (BOOL)textField:(LEAmountInputTextField *)textField shouldChangeAmount:(NSNumber *)amount; 35 | 36 | /** 37 | * Tells the delegate that the amount changed. It does not call this method when you programmatically set the amount. 38 | * 39 | * @param textField The text field object that is notifying you of the change. 40 | * @param amount The amount that was changed. 41 | */ 42 | - (void)textField:(LEAmountInputTextField *)textField didChangeAmount:(NSNumber *)amount; 43 | 44 | @end 45 | 46 | /** 47 | * The `LEAmountInputTextField` class is a `UITextField` subclass with a `LENumberPad` inputView. 48 | */ 49 | @interface LEAmountInputTextField : UITextField 50 | 51 | /** 52 | * The receiver’s delegate. 53 | * 54 | * You can you the delegate to respond to text field changes, like the amount. 55 | */ 56 | @property (nonatomic, weak) id delegate; 57 | 58 | /** 59 | * The number pad used in the receiver's inputView. 60 | * 61 | * Supports customization using the `dataSource` and `delegate` protocols. 62 | * 63 | * @see LENumberPad class. 64 | */ 65 | @property (nonatomic, strong) LENumberPad *numberPad; 66 | 67 | /** 68 | * The number style of the `LEAmountInputTextField` text. 69 | */ 70 | @property (nonatomic) NSNumberFormatterStyle numberStyle; 71 | 72 | /** 73 | * The amount value of the `LEAmountInputTextField`. 74 | */ 75 | @property (nonatomic, strong) NSNumber *amount; 76 | 77 | /** 78 | * Initializes a new `LEAmountInputTextField` with the specified frame rectangle and number style. 79 | * 80 | * @param frame The frame rectangle for the view, measured in points. 81 | * @param numberStyle The number style of the view. Sets the numberStyle of the `numberFormatter`. 82 | * 83 | * @return An initialized `LEAmountInputTextField` or nil if couldn't be created. 84 | */ 85 | - (instancetype)initWithFrame:(CGRect)frame numberStyle:(NSNumberFormatterStyle)numberStyle; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /LEAmountInputView/LEAmountInputTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // LEAmountInputTextField.m 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 6/10/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "LEAmountInputTextField.h" 10 | #import "NSNumberFormatter+LEAmountInputView.h" 11 | 12 | @interface LEAmountInputTextField () 13 | 14 | @property (nonatomic, strong) NSNumberFormatter *numberFormatter; 15 | 16 | @end 17 | 18 | @implementation LEAmountInputTextField 19 | 20 | @synthesize delegate; 21 | 22 | - (instancetype)initWithFrame:(CGRect)frame numberStyle:(NSNumberFormatterStyle)numberStyle; 23 | { 24 | self = [self initWithFrame:frame]; 25 | if (self) { 26 | self.numberStyle = numberStyle; 27 | } 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame 32 | { 33 | self = [super initWithFrame:frame]; 34 | if (self) { 35 | [self initialize]; 36 | } 37 | return self; 38 | } 39 | 40 | - (instancetype)initWithCoder:(NSCoder *)coder 41 | { 42 | self = [super initWithCoder:coder]; 43 | if (self) { 44 | [self initialize]; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)initialize; 50 | { 51 | self.textColor = [UIColor colorWithWhite:0.3f alpha:1.0f]; 52 | self.font = [UIFont systemFontOfSize:40.0f]; 53 | self.textAlignment = NSTextAlignmentRight; 54 | self.placeholder = [self.numberFormatter currencyString:nil]; 55 | self.inputView = self.numberPad; 56 | } 57 | 58 | #pragma mark - Override Properties 59 | 60 | - (LENumberPad *)numberPad 61 | { 62 | if (!_numberPad) { 63 | _numberPad = [[LENumberPad alloc] initWithFrame:CGRectZero]; 64 | _numberPad.translatesAutoresizingMaskIntoConstraints = NO; 65 | _numberPad.layer.borderColor = [UIColor colorWithWhite:0.9f alpha:1.0f].CGColor; 66 | _numberPad.layer.borderWidth = 1.0f; 67 | _numberPad.dataSource = self; 68 | _numberPad.delegate = self; 69 | } 70 | return _numberPad; 71 | } 72 | 73 | - (NSNumberFormatter *)numberFormatter 74 | { 75 | if (!_numberFormatter) { 76 | _numberFormatter = [NSNumberFormatter new]; 77 | } 78 | return _numberFormatter; 79 | } 80 | 81 | - (void)setAmount:(NSNumber *)amount 82 | { 83 | if (amount.doubleValue) { 84 | self.text = [self.numberFormatter stringFromNumber:amount]; 85 | } else { 86 | self.text = nil; 87 | } 88 | } 89 | 90 | - (NSNumber *)amount; 91 | { 92 | return [self.numberFormatter amountFromString:self.text]; 93 | } 94 | 95 | - (void)setNumberStyle:(NSNumberFormatterStyle)numberStyle 96 | { 97 | self.numberFormatter.numberStyle = numberStyle; 98 | 99 | self.placeholder = [self.numberFormatter currencyString:nil]; 100 | } 101 | 102 | - (NSNumberFormatterStyle)numberStyle 103 | { 104 | return self.numberFormatter.numberStyle; 105 | } 106 | 107 | #pragma mark - LENumberPadDataSource 108 | 109 | - (NSInteger)numberOfColumnsInNumberPad:(LENumberPad *)numberPad; 110 | { 111 | return 3; 112 | } 113 | 114 | - (NSInteger)numberOfRowsInNumberPad:(LENumberPad *)numberPad; 115 | { 116 | return 4; 117 | } 118 | 119 | - (NSString *)numberPad:(LENumberPad *)numberPad buttonTitleForButtonAtIndexPath:(NSIndexPath *)indexPath; 120 | { 121 | if (indexPath.item == 9) { 122 | return @"C"; 123 | } else if (indexPath.item == 10) { 124 | return @"0"; 125 | } else if (indexPath.item == 11) { 126 | return @"00"; 127 | } 128 | return [NSString stringWithFormat:@"%d", (int)indexPath.item + 1]; 129 | } 130 | 131 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonTitleColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 132 | { 133 | if (indexPath.item == 9) { 134 | return [UIColor orangeColor]; 135 | } 136 | return [UIColor colorWithWhite:0.3f alpha:1.0f]; 137 | } 138 | 139 | - (UIFont *)numberPad:(LENumberPad *)numberPad buttonTitleFontForButtonAtIndexPath:(NSIndexPath *)indexPath; 140 | { 141 | return [UIFont systemFontOfSize:40.0f]; 142 | } 143 | 144 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonBackgroundColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 145 | { 146 | return [UIColor whiteColor]; 147 | } 148 | 149 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonBackgroundHighlightedColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 150 | { 151 | return [UIColor colorWithWhite:0.9f alpha:1.0f]; 152 | } 153 | 154 | #pragma mark - LENumberPadDelegate 155 | 156 | - (void)numberPad:(LENumberPad *)numberPad didSelectButtonAtIndexPath:(NSIndexPath *)indexPath 157 | { 158 | NSNumber *amount = @0; 159 | 160 | if (indexPath.item != 9) { 161 | UIButton *button = [numberPad buttonAtIndexPath:indexPath]; 162 | NSMutableString *string = [NSMutableString stringWithString:self.text]; 163 | if (self.selectedTextRange) { 164 | NSInteger idx = [self offsetFromPosition:self.beginningOfDocument toPosition:self.selectedTextRange.start]; 165 | [string insertString:button.titleLabel.text atIndex:idx]; 166 | } else { 167 | [string appendString:button.titleLabel.text]; 168 | } 169 | amount = [self.numberFormatter amountFromString:string]; 170 | } 171 | 172 | if ([amount isEqualToNumber:self.amount] || ![self shouldChangeAmount:amount]) { 173 | return; 174 | } 175 | 176 | self.amount = amount; 177 | 178 | [self didChangeAmount:amount]; 179 | } 180 | 181 | #pragma mark - Private 182 | 183 | - (BOOL)shouldChangeAmount:(NSNumber *)amount 184 | { 185 | if ([delegate respondsToSelector:@selector(textField:shouldChangeAmount:)]) { 186 | return [delegate textField:self shouldChangeAmount:amount]; 187 | } 188 | return YES; 189 | } 190 | 191 | - (void)didChangeAmount:(NSNumber *)amount 192 | { 193 | if ([delegate respondsToSelector:@selector(textField:didChangeAmount:)]) { 194 | [delegate textField:self didChangeAmount:amount]; 195 | } 196 | } 197 | 198 | @end 199 | -------------------------------------------------------------------------------- /LEAmountInputView/LEAmountInputView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LEAmountInputView.h 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 4/29/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "LEAmountInputTextField.h" 12 | 13 | /** 14 | * The `LEAmountInputView` class is an amount input view inspired by Square's design. 15 | */ 16 | @interface LEAmountInputView : UIView 17 | 18 | /** 19 | * The textField of the `LEAmountInputView`. 20 | */ 21 | @property (nonatomic, strong) LEAmountInputTextField *textField; 22 | 23 | /** 24 | * Initializes a new `LEAmountInputView` with the specified frame rectangle and number style. 25 | * 26 | * @param frame The frame rectangle for the view, measured in points. 27 | * @param numberStyle The number style of the view. Sets the numberStyle of the textField's `numberFormatter`. 28 | * 29 | * @return An initialized `LEAmountInputView` or nil if couldn't be created. 30 | */ 31 | - (instancetype)initWithFrame:(CGRect)frame numberStyle:(NSNumberFormatterStyle)numberStyle; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /LEAmountInputView/LEAmountInputView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LEAmountInputView.m 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 4/29/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "LEAmountInputView.h" 10 | 11 | @interface LEAmountInputView () 12 | 13 | @end 14 | 15 | @implementation LEAmountInputView 16 | 17 | - (instancetype)initWithFrame:(CGRect)frame numberStyle:(NSNumberFormatterStyle)numberStyle; 18 | { 19 | self = [self initWithFrame:frame]; 20 | if (self) { 21 | self.textField.numberStyle = numberStyle; 22 | } 23 | return self; 24 | } 25 | 26 | - (instancetype)initWithFrame:(CGRect)frame 27 | { 28 | self = [super initWithFrame:frame]; 29 | if (self) { 30 | [self initialize]; 31 | } 32 | return self; 33 | } 34 | 35 | - (instancetype)initWithCoder:(NSCoder *)coder 36 | { 37 | self = [super initWithCoder:coder]; 38 | if (self) { 39 | [self initialize]; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)initialize; 45 | { 46 | self.backgroundColor = [UIColor whiteColor]; 47 | 48 | self.layer.borderColor = [UIColor colorWithWhite:0.9f alpha:1.0f].CGColor; 49 | self.layer.borderWidth = 1.0f; 50 | 51 | [self addSubview:self.textField]; 52 | [self addSubview:self.numberPad]; 53 | 54 | NSDictionary *views = @{@"textField": self.textField, @"numberPad": self.numberPad}; 55 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-20-[textField]-20-|" options:0 metrics:0 views:views]]; 56 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[numberPad]|" options:0 metrics:0 views:views]]; 57 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[textField][numberPad]|" options:0 metrics:0 views:views]]; 58 | [self addConstraint:[NSLayoutConstraint constraintWithItem:self.textField attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.numberPad attribute:NSLayoutAttributeHeight multiplier:1.0f / self.numberPad.numberOfRows constant:0]]; 59 | } 60 | 61 | #pragma mark - Override Properties 62 | 63 | - (LEAmountInputTextField *)textField 64 | { 65 | if (!_textField) { 66 | _textField = [[LEAmountInputTextField alloc] initWithFrame:CGRectZero]; 67 | _textField.translatesAutoresizingMaskIntoConstraints = NO; 68 | _textField.backgroundColor = [UIColor clearColor]; 69 | _textField.enabled = NO; 70 | } 71 | return _textField; 72 | } 73 | 74 | - (LENumberPad *)numberPad 75 | { 76 | return self.textField.numberPad; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /LEAmountInputView/LENumberPad.h: -------------------------------------------------------------------------------- 1 | // 2 | // LENumberPad.h 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 5/13/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class LENumberPad; 12 | 13 | @protocol LENumberPadDataSource 14 | 15 | - (NSInteger)numberOfColumnsInNumberPad:(LENumberPad *)numberPad; 16 | - (NSInteger)numberOfRowsInNumberPad:(LENumberPad *)numberPad; 17 | - (NSString *)numberPad:(LENumberPad *)numberPad buttonTitleForButtonAtIndexPath:(NSIndexPath *)indexPath; 18 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonTitleColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 19 | - (UIFont *)numberPad:(LENumberPad *)numberPad buttonTitleFontForButtonAtIndexPath:(NSIndexPath *)indexPath; 20 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonBackgroundColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 21 | - (UIColor *)numberPad:(LENumberPad *)numberPad buttonBackgroundHighlightedColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 22 | 23 | @end 24 | 25 | @protocol LENumberPadDelegate 26 | 27 | @optional 28 | - (void)numberPad:(LENumberPad *)numberPad didSelectButtonAtIndexPath:(NSIndexPath *)indexPath; 29 | 30 | @end 31 | 32 | /** 33 | * The `LENumberPad` class is a number pad view. 34 | * 35 | * Customize using the `dataSource` and `delegate` protocols. 36 | */ 37 | @interface LENumberPad : UIView 38 | 39 | @property (nonatomic, weak) id dataSource; 40 | @property (nonatomic, weak) id delegate; 41 | 42 | - (UIButton *)buttonAtIndexPath:(NSIndexPath *)indexPath; 43 | - (NSIndexPath *)indexPathForButton:(UIButton *)button; 44 | 45 | - (NSInteger)numberOfColumns; 46 | - (NSInteger)numberOfRows; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /LEAmountInputView/LENumberPad.m: -------------------------------------------------------------------------------- 1 | // 2 | // LENumberPad.m 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 5/13/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "LENumberPad.h" 10 | #import "LENumberPadCollectionViewCell.h" 11 | #import "UIImage+LENumberPad.h" 12 | 13 | @interface LENumberPad () 14 | 15 | @property (nonatomic, strong) UICollectionView *collectionView; 16 | 17 | @end 18 | 19 | @implementation LENumberPad 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame 22 | { 23 | self = [super initWithFrame:frame]; 24 | if (self) { 25 | [self initialize]; 26 | } 27 | return self; 28 | } 29 | 30 | - (instancetype)initWithCoder:(NSCoder *)coder 31 | { 32 | self = [super initWithCoder:coder]; 33 | if (self) { 34 | [self initialize]; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)initialize; 40 | { 41 | self.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; 42 | 43 | [self addSubview:self.collectionView]; 44 | 45 | NSDictionary *views = @{@"collectionView": self.collectionView}; 46 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[collectionView]|" options:0 metrics:0 views:views]]; 47 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[collectionView]|" options:0 metrics:0 views:views]]; 48 | } 49 | 50 | - (void)layoutSubviews 51 | { 52 | [self.collectionView.collectionViewLayout invalidateLayout]; 53 | 54 | [super layoutSubviews]; 55 | } 56 | 57 | #pragma mark - Override Properties 58 | 59 | - (UICollectionView *)collectionView 60 | { 61 | if (!_collectionView) { 62 | UICollectionViewFlowLayout *collectionViewLayout = [UICollectionViewFlowLayout new]; 63 | collectionViewLayout.minimumLineSpacing = 1.0f; 64 | collectionViewLayout.minimumInteritemSpacing = 1.0f; 65 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:collectionViewLayout]; 66 | _collectionView.translatesAutoresizingMaskIntoConstraints = NO; 67 | _collectionView.dataSource = self; 68 | _collectionView.delegate = self; 69 | _collectionView.backgroundColor = [UIColor clearColor]; 70 | _collectionView.allowsSelection = NO; 71 | _collectionView.scrollEnabled = NO; 72 | [_collectionView registerClass:[LENumberPadCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([LENumberPadCollectionViewCell class])]; 73 | } 74 | return _collectionView; 75 | } 76 | 77 | #pragma mark - UICollectionViewDataSource 78 | 79 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 80 | { 81 | return [self numberOfColumns] * [self numberOfRows]; 82 | } 83 | 84 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath; 85 | { 86 | LENumberPadCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([LENumberPadCollectionViewCell class]) forIndexPath:indexPath]; 87 | 88 | NSString *title = [self buttonTitleForButtonAtIndexPath:indexPath]; 89 | [cell.button setTitle:title forState:UIControlStateNormal]; 90 | 91 | UIColor *titleColor = [self buttonTitleColorForButtonAtIndexPath:indexPath]; 92 | [cell.button setTitleColor:titleColor forState:UIControlStateNormal]; 93 | 94 | UIFont *font = [self buttonTitleFontForButtonAtIndexPath:indexPath]; 95 | cell.button.titleLabel.font = font; 96 | 97 | UIColor *backgroundColor = [self buttonBackgroundColorForButtonAtIndexPath:indexPath]; 98 | UIImage *backgroundImage = [UIImage imageFromColor:backgroundColor]; 99 | [cell.button setBackgroundImage:backgroundImage forState:UIControlStateNormal]; 100 | backgroundColor = [self buttonBackgroundHighlightedColorForButtonAtIndexPath:indexPath]; 101 | backgroundImage = [UIImage imageFromColor:backgroundColor]; 102 | [cell.button setBackgroundImage:backgroundImage forState:UIControlStateHighlighted]; 103 | [cell.button setBackgroundImage:backgroundImage forState:UIControlStateSelected]; 104 | 105 | [cell.button addTarget:self action:@selector(didTouchOnButton:) forControlEvents:UIControlEventTouchUpInside]; 106 | 107 | return cell; 108 | } 109 | 110 | #pragma mark - UICollectionViewDelegateFlowLayout 111 | 112 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath; 113 | { 114 | NSInteger numberOfColumns = [self numberOfColumns]; 115 | NSInteger numberOfRows = [self numberOfRows]; 116 | 117 | CGFloat width = collectionView.frame.size.width / numberOfColumns; 118 | CGFloat height = collectionView.frame.size.height / numberOfRows; 119 | 120 | CGFloat interitemSpacing = collectionViewLayout.minimumInteritemSpacing * (((float)numberOfColumns - 1.0f) / (float)numberOfColumns); 121 | CGFloat lineSpacing = collectionViewLayout.minimumLineSpacing * (((float)numberOfRows - 1.0f) / (float)numberOfRows); 122 | 123 | return (CGSize){floor(width - interitemSpacing), height - lineSpacing}; 124 | } 125 | 126 | #pragma mark - IBActions 127 | 128 | - (IBAction)didTouchOnButton:(UIButton *)button 129 | { 130 | if ([self.delegate respondsToSelector:@selector(numberPad:didSelectButtonAtIndexPath:)]) { 131 | NSIndexPath *indexPath = [self indexPathForButton:button]; 132 | [self.delegate numberPad:self didSelectButtonAtIndexPath:indexPath]; 133 | } 134 | } 135 | 136 | #pragma mark - Helpers 137 | 138 | - (UIButton *)buttonAtIndexPath:(NSIndexPath *)indexPath; 139 | { 140 | LENumberPadCollectionViewCell *cell = (LENumberPadCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; 141 | return cell.button; 142 | } 143 | 144 | - (NSIndexPath *)indexPathForButton:(UIButton *)button; 145 | { 146 | CGPoint point = [button convertPoint:CGPointZero toView:self.collectionView]; 147 | return [self.collectionView indexPathForItemAtPoint:point]; 148 | } 149 | 150 | - (NSInteger)numberOfColumns; 151 | { 152 | return [self.dataSource numberOfColumnsInNumberPad:self]; 153 | } 154 | 155 | - (NSInteger)numberOfRows; 156 | { 157 | return [self.dataSource numberOfRowsInNumberPad:self]; 158 | } 159 | 160 | #pragma mark - Private 161 | 162 | - (NSString *)buttonTitleForButtonAtIndexPath:(NSIndexPath *)indexPath; 163 | { 164 | return [self.dataSource numberPad:self buttonTitleForButtonAtIndexPath:indexPath]; 165 | } 166 | 167 | - (UIColor *)buttonTitleColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 168 | { 169 | return [self.dataSource numberPad:self buttonTitleColorForButtonAtIndexPath:indexPath]; 170 | } 171 | 172 | - (UIFont *)buttonTitleFontForButtonAtIndexPath:(NSIndexPath *)indexPath; 173 | { 174 | return [self.dataSource numberPad:self buttonTitleFontForButtonAtIndexPath:indexPath]; 175 | } 176 | 177 | - (UIColor *)buttonBackgroundColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 178 | { 179 | return [self.dataSource numberPad:self buttonBackgroundColorForButtonAtIndexPath:indexPath]; 180 | } 181 | 182 | - (UIColor *)buttonBackgroundHighlightedColorForButtonAtIndexPath:(NSIndexPath *)indexPath; 183 | { 184 | return [self.dataSource numberPad:self buttonBackgroundHighlightedColorForButtonAtIndexPath:indexPath]; 185 | } 186 | 187 | @end 188 | -------------------------------------------------------------------------------- /LEAmountInputView/LENumberPadCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // LENumberPadCollectionViewCell.h 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 5/13/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LENumberPadCollectionViewCell : UICollectionViewCell 12 | 13 | @property (nonatomic, strong) UIButton *button; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /LEAmountInputView/LENumberPadCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // LENumberPadCollectionViewCell.m 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 5/13/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "LENumberPadCollectionViewCell.h" 10 | 11 | @implementation LENumberPadCollectionViewCell 12 | 13 | - (instancetype)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | [self initialize]; 18 | } 19 | return self; 20 | } 21 | 22 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 23 | { 24 | self = [super initWithCoder:aDecoder]; 25 | if (self) { 26 | [self initialize]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)initialize 32 | { 33 | self.layer.rasterizationScale = [[UIScreen mainScreen] scale]; 34 | self.layer.shouldRasterize = YES; 35 | 36 | [self.contentView addSubview:self.button]; 37 | 38 | NSDictionary *views = @{@"button": self.button}; 39 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[button]|" options:0 metrics:0 views:views]]; 40 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[button]|" options:0 metrics:0 views:views]]; 41 | } 42 | 43 | #pragma mark - Override Properties 44 | 45 | - (UIButton *)button 46 | { 47 | if (!_button) { 48 | _button = [UIButton buttonWithType:UIButtonTypeCustom]; 49 | _button.translatesAutoresizingMaskIntoConstraints = NO; 50 | _button.titleLabel.textAlignment = NSTextAlignmentCenter; 51 | } 52 | return _button; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /LEAmountInputView/NSNumberFormatter+LEAmountInputView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter+LEAmountInputView.h 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 6/10/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSNumberFormatter (LEAmountInputView) 12 | 13 | - (NSString *)currencyString:(NSString *)string; 14 | 15 | - (NSNumber *)amountFromString:(NSString *)string; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /LEAmountInputView/NSNumberFormatter+LEAmountInputView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter+LEAmountInputView.m 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 6/10/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "NSNumberFormatter+LEAmountInputView.h" 10 | 11 | @implementation NSNumberFormatter (LEAmountInputView) 12 | 13 | - (NSString *)currencyString:(NSString *)string; 14 | { 15 | NSNumber *amount = [self amountFromString:string]; 16 | return [self stringFromNumber:amount]; 17 | } 18 | 19 | - (NSNumber *)amountFromString:(NSString *)string; 20 | { 21 | string = [self sanitizedString:string]; 22 | if (string.doubleValue == 0) { 23 | return @0; 24 | } 25 | NSDecimalNumber *digits = [NSDecimalNumber decimalNumberWithString:string]; 26 | NSDecimalNumber *decimalPlace = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:pow(10.0, self.minimumFractionDigits)]; 27 | return [digits decimalNumberByDividingBy:decimalPlace]; 28 | } 29 | 30 | #pragma mark - Private 31 | 32 | - (NSString *)sanitizedString:(NSString *)string; 33 | { 34 | return [[string componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:[NSString string]]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /LEAmountInputView/UIImage+LENumberPad.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+LENumberPad.h 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 4/30/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (LENumberPad) 12 | 13 | + (UIImage *)imageFromColor:(UIColor *)color; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /LEAmountInputView/UIImage+LENumberPad.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+LENumberPad.m 3 | // LEAmountInputView 4 | // 5 | // Created by Lasha Efremidze on 4/30/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "UIImage+LENumberPad.h" 10 | 11 | @implementation UIImage (LENumberPad) 12 | 13 | + (UIImage *)imageFromColor:(UIColor *)color; 14 | { 15 | CGRect rect = CGRectMake(0, 0, 1, 1); 16 | UIGraphicsBeginImageContext(rect.size); 17 | CGContextRef context = UIGraphicsGetCurrentContext(); 18 | CGContextSetFillColorWithColor(context, color.CGColor); 19 | CGContextFillRect(context, rect); 20 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 21 | UIGraphicsEndImageContext(); 22 | return image; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8B2E92901AF6EB9A00F94CB6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B2E928F1AF6EB9A00F94CB6 /* main.m */; }; 11 | 8B2E92931AF6EB9A00F94CB6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B2E92921AF6EB9A00F94CB6 /* AppDelegate.m */; }; 12 | 8B2E92961AF6EB9A00F94CB6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B2E92951AF6EB9A00F94CB6 /* ViewController.m */; }; 13 | 8B2E92991AF6EB9A00F94CB6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8B2E92971AF6EB9A00F94CB6 /* Main.storyboard */; }; 14 | 8B2E929B1AF6EB9A00F94CB6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B2E929A1AF6EB9A00F94CB6 /* Images.xcassets */; }; 15 | 8B2E929E1AF6EB9A00F94CB6 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8B2E929C1AF6EB9A00F94CB6 /* LaunchScreen.xib */; }; 16 | 8B2E92C11AF6EC1300F94CB6 /* LEAmountInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B2E92B71AF6EC1300F94CB6 /* LEAmountInputView.m */; }; 17 | 8B3FBB951B03E13F00DE7B2F /* UIImage+LENumberPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B3FBB941B03E13F00DE7B2F /* UIImage+LENumberPad.m */; }; 18 | 8B3FBB9E1B0402B700DE7B2F /* LENumberPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B3FBB9D1B0402B700DE7B2F /* LENumberPad.m */; }; 19 | 8B3FBBA11B04036800DE7B2F /* LENumberPadCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B3FBBA01B04036800DE7B2F /* LENumberPadCollectionViewCell.m */; }; 20 | 8BAF04051B288D7000159874 /* LEAmountInputTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BAF04041B288D7000159874 /* LEAmountInputTextField.m */; }; 21 | 8BAF040B1B28906200159874 /* NSNumberFormatter+LEAmountInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BAF040A1B28906200159874 /* NSNumberFormatter+LEAmountInputView.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 8B2E928A1AF6EB9A00F94CB6 /* LEAmountInputViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LEAmountInputViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 8B2E928E1AF6EB9A00F94CB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 8B2E928F1AF6EB9A00F94CB6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 28 | 8B2E92911AF6EB9A00F94CB6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 29 | 8B2E92921AF6EB9A00F94CB6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 30 | 8B2E92941AF6EB9A00F94CB6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 31 | 8B2E92951AF6EB9A00F94CB6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 32 | 8B2E92981AF6EB9A00F94CB6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | 8B2E929A1AF6EB9A00F94CB6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | 8B2E929D1AF6EB9A00F94CB6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 35 | 8B2E92B61AF6EC1300F94CB6 /* LEAmountInputView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LEAmountInputView.h; sourceTree = ""; }; 36 | 8B2E92B71AF6EC1300F94CB6 /* LEAmountInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LEAmountInputView.m; sourceTree = ""; }; 37 | 8B3FBB931B03E13F00DE7B2F /* UIImage+LENumberPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+LENumberPad.h"; sourceTree = ""; }; 38 | 8B3FBB941B03E13F00DE7B2F /* UIImage+LENumberPad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+LENumberPad.m"; sourceTree = ""; }; 39 | 8B3FBB9C1B0402B700DE7B2F /* LENumberPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LENumberPad.h; sourceTree = ""; }; 40 | 8B3FBB9D1B0402B700DE7B2F /* LENumberPad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LENumberPad.m; sourceTree = ""; }; 41 | 8B3FBB9F1B04036800DE7B2F /* LENumberPadCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LENumberPadCollectionViewCell.h; sourceTree = ""; }; 42 | 8B3FBBA01B04036800DE7B2F /* LENumberPadCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LENumberPadCollectionViewCell.m; sourceTree = ""; }; 43 | 8BAF04031B288D7000159874 /* LEAmountInputTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LEAmountInputTextField.h; sourceTree = ""; }; 44 | 8BAF04041B288D7000159874 /* LEAmountInputTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LEAmountInputTextField.m; sourceTree = ""; }; 45 | 8BAF04091B28906200159874 /* NSNumberFormatter+LEAmountInputView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumberFormatter+LEAmountInputView.h"; sourceTree = ""; }; 46 | 8BAF040A1B28906200159874 /* NSNumberFormatter+LEAmountInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumberFormatter+LEAmountInputView.m"; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 8B2E92871AF6EB9A00F94CB6 /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 8B2E92811AF6EB9A00F94CB6 = { 61 | isa = PBXGroup; 62 | children = ( 63 | 8B2E92B31AF6EC1300F94CB6 /* LEAmountInputView */, 64 | 8B2E928C1AF6EB9A00F94CB6 /* LEAmountInputViewDemo */, 65 | 8B2E928B1AF6EB9A00F94CB6 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | 8B2E928B1AF6EB9A00F94CB6 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 8B2E928A1AF6EB9A00F94CB6 /* LEAmountInputViewDemo.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | 8B2E928C1AF6EB9A00F94CB6 /* LEAmountInputViewDemo */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 8B2E92911AF6EB9A00F94CB6 /* AppDelegate.h */, 81 | 8B2E92921AF6EB9A00F94CB6 /* AppDelegate.m */, 82 | 8B2E92941AF6EB9A00F94CB6 /* ViewController.h */, 83 | 8B2E92951AF6EB9A00F94CB6 /* ViewController.m */, 84 | 8B2E92971AF6EB9A00F94CB6 /* Main.storyboard */, 85 | 8B2E929A1AF6EB9A00F94CB6 /* Images.xcassets */, 86 | 8B2E929C1AF6EB9A00F94CB6 /* LaunchScreen.xib */, 87 | 8B2E928D1AF6EB9A00F94CB6 /* Supporting Files */, 88 | ); 89 | path = LEAmountInputViewDemo; 90 | sourceTree = ""; 91 | }; 92 | 8B2E928D1AF6EB9A00F94CB6 /* Supporting Files */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 8B2E928E1AF6EB9A00F94CB6 /* Info.plist */, 96 | 8B2E928F1AF6EB9A00F94CB6 /* main.m */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | 8B2E92B31AF6EC1300F94CB6 /* LEAmountInputView */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 8BAF04031B288D7000159874 /* LEAmountInputTextField.h */, 105 | 8BAF04041B288D7000159874 /* LEAmountInputTextField.m */, 106 | 8B2E92B61AF6EC1300F94CB6 /* LEAmountInputView.h */, 107 | 8B2E92B71AF6EC1300F94CB6 /* LEAmountInputView.m */, 108 | 8B3FBB9C1B0402B700DE7B2F /* LENumberPad.h */, 109 | 8B3FBB9D1B0402B700DE7B2F /* LENumberPad.m */, 110 | 8B3FBB9F1B04036800DE7B2F /* LENumberPadCollectionViewCell.h */, 111 | 8B3FBBA01B04036800DE7B2F /* LENumberPadCollectionViewCell.m */, 112 | 8BAF04091B28906200159874 /* NSNumberFormatter+LEAmountInputView.h */, 113 | 8BAF040A1B28906200159874 /* NSNumberFormatter+LEAmountInputView.m */, 114 | 8B3FBB931B03E13F00DE7B2F /* UIImage+LENumberPad.h */, 115 | 8B3FBB941B03E13F00DE7B2F /* UIImage+LENumberPad.m */, 116 | ); 117 | path = LEAmountInputView; 118 | sourceTree = ""; 119 | }; 120 | /* End PBXGroup section */ 121 | 122 | /* Begin PBXNativeTarget section */ 123 | 8B2E92891AF6EB9A00F94CB6 /* LEAmountInputViewDemo */ = { 124 | isa = PBXNativeTarget; 125 | buildConfigurationList = 8B2E92AD1AF6EB9A00F94CB6 /* Build configuration list for PBXNativeTarget "LEAmountInputViewDemo" */; 126 | buildPhases = ( 127 | 8B2E92861AF6EB9A00F94CB6 /* Sources */, 128 | 8B2E92871AF6EB9A00F94CB6 /* Frameworks */, 129 | 8B2E92881AF6EB9A00F94CB6 /* Resources */, 130 | ); 131 | buildRules = ( 132 | ); 133 | dependencies = ( 134 | ); 135 | name = LEAmountInputViewDemo; 136 | productName = LEAmountInputViewDemo; 137 | productReference = 8B2E928A1AF6EB9A00F94CB6 /* LEAmountInputViewDemo.app */; 138 | productType = "com.apple.product-type.application"; 139 | }; 140 | /* End PBXNativeTarget section */ 141 | 142 | /* Begin PBXProject section */ 143 | 8B2E92821AF6EB9A00F94CB6 /* Project object */ = { 144 | isa = PBXProject; 145 | attributes = { 146 | LastUpgradeCheck = 0800; 147 | ORGANIZATIONNAME = "Lasha Efremidze"; 148 | TargetAttributes = { 149 | 8B2E92891AF6EB9A00F94CB6 = { 150 | CreatedOnToolsVersion = 6.4; 151 | }; 152 | }; 153 | }; 154 | buildConfigurationList = 8B2E92851AF6EB9A00F94CB6 /* Build configuration list for PBXProject "LEAmountInputViewDemo" */; 155 | compatibilityVersion = "Xcode 3.2"; 156 | developmentRegion = English; 157 | hasScannedForEncodings = 0; 158 | knownRegions = ( 159 | en, 160 | Base, 161 | ); 162 | mainGroup = 8B2E92811AF6EB9A00F94CB6; 163 | productRefGroup = 8B2E928B1AF6EB9A00F94CB6 /* Products */; 164 | projectDirPath = ""; 165 | projectRoot = ""; 166 | targets = ( 167 | 8B2E92891AF6EB9A00F94CB6 /* LEAmountInputViewDemo */, 168 | ); 169 | }; 170 | /* End PBXProject section */ 171 | 172 | /* Begin PBXResourcesBuildPhase section */ 173 | 8B2E92881AF6EB9A00F94CB6 /* Resources */ = { 174 | isa = PBXResourcesBuildPhase; 175 | buildActionMask = 2147483647; 176 | files = ( 177 | 8B2E92991AF6EB9A00F94CB6 /* Main.storyboard in Resources */, 178 | 8B2E929E1AF6EB9A00F94CB6 /* LaunchScreen.xib in Resources */, 179 | 8B2E929B1AF6EB9A00F94CB6 /* Images.xcassets in Resources */, 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | }; 183 | /* End PBXResourcesBuildPhase section */ 184 | 185 | /* Begin PBXSourcesBuildPhase section */ 186 | 8B2E92861AF6EB9A00F94CB6 /* Sources */ = { 187 | isa = PBXSourcesBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | 8B3FBBA11B04036800DE7B2F /* LENumberPadCollectionViewCell.m in Sources */, 191 | 8BAF040B1B28906200159874 /* NSNumberFormatter+LEAmountInputView.m in Sources */, 192 | 8B3FBB951B03E13F00DE7B2F /* UIImage+LENumberPad.m in Sources */, 193 | 8B2E92961AF6EB9A00F94CB6 /* ViewController.m in Sources */, 194 | 8B3FBB9E1B0402B700DE7B2F /* LENumberPad.m in Sources */, 195 | 8B2E92931AF6EB9A00F94CB6 /* AppDelegate.m in Sources */, 196 | 8B2E92901AF6EB9A00F94CB6 /* main.m in Sources */, 197 | 8B2E92C11AF6EC1300F94CB6 /* LEAmountInputView.m in Sources */, 198 | 8BAF04051B288D7000159874 /* LEAmountInputTextField.m in Sources */, 199 | ); 200 | runOnlyForDeploymentPostprocessing = 0; 201 | }; 202 | /* End PBXSourcesBuildPhase section */ 203 | 204 | /* Begin PBXVariantGroup section */ 205 | 8B2E92971AF6EB9A00F94CB6 /* Main.storyboard */ = { 206 | isa = PBXVariantGroup; 207 | children = ( 208 | 8B2E92981AF6EB9A00F94CB6 /* Base */, 209 | ); 210 | name = Main.storyboard; 211 | sourceTree = ""; 212 | }; 213 | 8B2E929C1AF6EB9A00F94CB6 /* LaunchScreen.xib */ = { 214 | isa = PBXVariantGroup; 215 | children = ( 216 | 8B2E929D1AF6EB9A00F94CB6 /* Base */, 217 | ); 218 | name = LaunchScreen.xib; 219 | sourceTree = ""; 220 | }; 221 | /* End PBXVariantGroup section */ 222 | 223 | /* Begin XCBuildConfiguration section */ 224 | 8B2E92AB1AF6EB9A00F94CB6 /* Debug */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | ALWAYS_SEARCH_USER_PATHS = NO; 228 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 229 | CLANG_CXX_LIBRARY = "libc++"; 230 | CLANG_ENABLE_MODULES = YES; 231 | CLANG_ENABLE_OBJC_ARC = YES; 232 | CLANG_WARN_BOOL_CONVERSION = YES; 233 | CLANG_WARN_CONSTANT_CONVERSION = YES; 234 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INFINITE_RECURSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 246 | ENABLE_STRICT_OBJC_MSGSEND = YES; 247 | ENABLE_TESTABILITY = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_DYNAMIC_NO_PIC = NO; 250 | GCC_NO_COMMON_BLOCKS = YES; 251 | GCC_OPTIMIZATION_LEVEL = 0; 252 | GCC_PREPROCESSOR_DEFINITIONS = ( 253 | "DEBUG=1", 254 | "$(inherited)", 255 | ); 256 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 259 | GCC_WARN_UNDECLARED_SELECTOR = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 261 | GCC_WARN_UNUSED_FUNCTION = YES; 262 | GCC_WARN_UNUSED_VARIABLE = YES; 263 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 264 | MTL_ENABLE_DEBUG_INFO = YES; 265 | ONLY_ACTIVE_ARCH = YES; 266 | SDKROOT = iphoneos; 267 | TARGETED_DEVICE_FAMILY = "1,2"; 268 | }; 269 | name = Debug; 270 | }; 271 | 8B2E92AC1AF6EB9A00F94CB6 /* Release */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ALWAYS_SEARCH_USER_PATHS = NO; 275 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 276 | CLANG_CXX_LIBRARY = "libc++"; 277 | CLANG_ENABLE_MODULES = YES; 278 | CLANG_ENABLE_OBJC_ARC = YES; 279 | CLANG_WARN_BOOL_CONVERSION = YES; 280 | CLANG_WARN_CONSTANT_CONVERSION = YES; 281 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 282 | CLANG_WARN_EMPTY_BODY = YES; 283 | CLANG_WARN_ENUM_CONVERSION = YES; 284 | CLANG_WARN_INFINITE_RECURSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 291 | COPY_PHASE_STRIP = NO; 292 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 293 | ENABLE_NS_ASSERTIONS = NO; 294 | ENABLE_STRICT_OBJC_MSGSEND = YES; 295 | GCC_C_LANGUAGE_STANDARD = gnu99; 296 | GCC_NO_COMMON_BLOCKS = YES; 297 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 298 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 299 | GCC_WARN_UNDECLARED_SELECTOR = YES; 300 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 301 | GCC_WARN_UNUSED_FUNCTION = YES; 302 | GCC_WARN_UNUSED_VARIABLE = YES; 303 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 304 | MTL_ENABLE_DEBUG_INFO = NO; 305 | SDKROOT = iphoneos; 306 | TARGETED_DEVICE_FAMILY = "1,2"; 307 | VALIDATE_PRODUCT = YES; 308 | }; 309 | name = Release; 310 | }; 311 | 8B2E92AE1AF6EB9A00F94CB6 /* Debug */ = { 312 | isa = XCBuildConfiguration; 313 | buildSettings = { 314 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 315 | INFOPLIST_FILE = LEAmountInputViewDemo/Info.plist; 316 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 317 | PRODUCT_BUNDLE_IDENTIFIER = "com.efremidze.$(PRODUCT_NAME:rfc1034identifier)"; 318 | PRODUCT_NAME = "$(TARGET_NAME)"; 319 | }; 320 | name = Debug; 321 | }; 322 | 8B2E92AF1AF6EB9A00F94CB6 /* Release */ = { 323 | isa = XCBuildConfiguration; 324 | buildSettings = { 325 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 326 | INFOPLIST_FILE = LEAmountInputViewDemo/Info.plist; 327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 328 | PRODUCT_BUNDLE_IDENTIFIER = "com.efremidze.$(PRODUCT_NAME:rfc1034identifier)"; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | }; 331 | name = Release; 332 | }; 333 | /* End XCBuildConfiguration section */ 334 | 335 | /* Begin XCConfigurationList section */ 336 | 8B2E92851AF6EB9A00F94CB6 /* Build configuration list for PBXProject "LEAmountInputViewDemo" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 8B2E92AB1AF6EB9A00F94CB6 /* Debug */, 340 | 8B2E92AC1AF6EB9A00F94CB6 /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | 8B2E92AD1AF6EB9A00F94CB6 /* Build configuration list for PBXNativeTarget "LEAmountInputViewDemo" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | 8B2E92AE1AF6EB9A00F94CB6 /* Debug */, 349 | 8B2E92AF1AF6EB9A00F94CB6 /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | /* End XCConfigurationList section */ 355 | }; 356 | rootObject = 8B2E92821AF6EB9A00F94CB6 /* Project object */; 357 | } 358 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo.xcodeproj/xcshareddata/xcschemes/LEAmountInputViewDemo.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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 5/3/15. 6 | // Copyright (c) 2015 Lasha Efremidze. 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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 5/3/15. 6 | // Copyright (c) 2015 Lasha Efremidze. 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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LEAmountInputViewDemo/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 | 0.1.6 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 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 5/3/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 5/3/15. 6 | // Copyright (c) 2015 Lasha Efremidze. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LEAmountInputView.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | [self setup]; 23 | } 24 | 25 | #pragma mark - LEAmountInputView 26 | 27 | - (void)setup 28 | { 29 | LEAmountInputView *amountInputView = [[LEAmountInputView alloc] initWithFrame:CGRectZero numberStyle:NSNumberFormatterCurrencyStyle]; 30 | amountInputView.translatesAutoresizingMaskIntoConstraints = NO; 31 | amountInputView.textField.delegate = self; 32 | [self.view addSubview:amountInputView]; 33 | 34 | NSDictionary *views = NSDictionaryOfVariableBindings(amountInputView); 35 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-10-[amountInputView]-10-|" options:0 metrics:0 views:views]]; 36 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-20-[amountInputView]-10-|" options:0 metrics:0 views:views]]; 37 | } 38 | 39 | #pragma mark - LEAmountInputTextFieldDelegate 40 | 41 | - (BOOL)textField:(LEAmountInputTextField *)textField shouldChangeAmount:(NSNumber *)amount 42 | { 43 | NSLog(@"%s %@", __PRETTY_FUNCTION__, amount); 44 | 45 | double maxAmount = 999999.99; 46 | double totalAmount = amount.doubleValue; 47 | if (totalAmount > maxAmount) { 48 | textField.amount = @(maxAmount); 49 | return NO; 50 | } 51 | return YES; 52 | } 53 | 54 | - (void)textField:(LEAmountInputTextField *)textField didChangeAmount:(NSNumber *)amount 55 | { 56 | NSLog(@"%s %@", __PRETTY_FUNCTION__, amount); 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /LEAmountInputViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LEAmountInputViewDemo 4 | // 5 | // Created by Lasha Efremidze on 5/3/15. 6 | // Copyright (c) 2015 Lasha Efremidze. 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Lasha Efremidze 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LEAmountInputView 2 | 3 | [![CI Status](http://img.shields.io/travis/efremidze/LEAmountInputView.svg?style=flat)](https://travis-ci.org/efremidze/LEAmountInputView) 4 | [![Version](https://img.shields.io/cocoapods/v/LEAmountInputView.svg?style=flat)](http://cocoapods.org/pods/LEAmountInputView) 5 | [![License](https://img.shields.io/cocoapods/l/LEAmountInputView.svg?style=flat)](http://cocoapods.org/pods/LEAmountInputView) 6 | [![Platform](https://img.shields.io/cocoapods/p/LEAmountInputView.svg?style=flat)](http://cocoapods.org/pods/LEAmountInputView) 7 | 8 | ## Overview 9 | 10 | `LEAmountInputView` is an amount input view inspired by Square's design. 11 | 12 | ![LEAmountInputView Screenshot](Screenshots/example.gif) 13 | 14 | **Note:** If you like `LEAmountInputView`, checkout [NumPad](https://github.com/efremidze/NumPad). 15 | 16 | ## Installation 17 | 18 | LEAmountInputView is available through [CocoaPods](http://cocoapods.org). To install 19 | it, simply add the following line to your Podfile: 20 | 21 | ```ruby 22 | pod "LEAmountInputView" 23 | ``` 24 | 25 | ## Usage 26 | 27 | See the `LEAmountInputViewDemo` project for example usage. 28 | 29 | ### Import 30 | 31 | ```objc 32 | #import "LEAmountInputView.h" 33 | ``` 34 | 35 | ### Example 36 | 37 | ```objectivec 38 | LEAmountInputView *amountInputView = [[LEAmountInputView alloc] initWithFrame:self.view.frame numberStyle:NSNumberFormatterCurrencyStyle]; 39 | [self.view addSubview:amountInputView]; 40 | ``` 41 | 42 | ### LEAmountInputTextField 43 | 44 | If you want to use the textField standalone with the numberPad as an inputView, use `LEAmountInputTextField`. 45 | 46 | ## Contributions 47 | 48 | Contributions are totally welcome. 49 | 50 | ## License 51 | 52 | LEAmountInputView is available under the MIT license. See the LICENSE file for more info. 53 | -------------------------------------------------------------------------------- /Screenshots/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efremidze/LEAmountInputView/30a034bd34277ecea5a52dcc844241f33f8ad0bc/Screenshots/example.gif --------------------------------------------------------------------------------