Skip to content

Commit 849dca6

Browse files
committed
[fix] Avoid unnecessary defaults for alignement
1 parent 24ba914 commit 849dca6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Classes/MPNumericTextField.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,33 @@ @implementation MPNumericTextField
4343

4444
- (id)initWithCoder:(NSCoder *)aDecoder {
4545
if ((self = [super initWithCoder:aDecoder])) {
46-
[self setDefaults];
46+
[self setDefaultsWithForcedAlignment:NO];
4747
}
4848
return self;
4949
}
5050

5151
- (id)initWithFrame:(CGRect)frame {
5252
if ((self = [super initWithFrame:frame])) {
53-
[self setDefaults];
53+
[self setDefaultsWithForcedAlignment:NO];
5454
}
5555
return self;
5656
}
5757

5858
- (id)init {
5959
if ((self = [super init])) {
60-
[self setDefaults];
60+
[self setDefaultsWithForcedAlignment:YES];
6161
}
6262
return self;
6363
}
6464

65-
- (void) setDefaults {
65+
- (void) setDefaultsWithForcedAlignment:(BOOL)forceAlignment {
6666
self.locale = [NSLocale currentLocale];
6767
self.currencyCode = [self.locale objectForKey:NSLocaleCurrencyCode];
6868
self.keyboardType = UIKeyboardTypeDecimalPad;
6969
self.type = MPNumericTextFieldDecimal;
7070
self.delegate = self.numericDelegate;
71-
self.textAlignment = NSTextAlignmentRight;
71+
if (forceAlignment)
72+
self.textAlignment = NSTextAlignmentRight;
7273
}
7374

7475
- (void) setCurrencyCode:(NSString *)currencyCode {

0 commit comments

Comments
 (0)