forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputOnlyTextPlainCell.m
More file actions
executable file
·54 lines (49 loc) · 1.95 KB
/
InputOnlyTextPlainCell.m
File metadata and controls
executable file
·54 lines (49 loc) · 1.95 KB
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
//
// InputOnlyTextPlainCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-8-26.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "InputOnlyTextPlainCell.h"
@interface InputOnlyTextPlainCell ()
@property (strong, nonatomic) UITextField *textField;
@property (strong, nonatomic) NSString *phStr, *valueStr;
@property (assign,nonatomic) BOOL isSecure;
@end
@implementation InputOnlyTextPlainCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
if (!_textField) {
_textField = [[UITextField alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 7.0, kScreen_Width-kPaddingLeftWidth*2, 30)];
_textField.backgroundColor = [UIColor clearColor];
_textField.borderStyle = UITextBorderStyleNone;
_textField.font = [UIFont systemFontOfSize:16];
[_textField addTarget:self action:@selector(textValueChanged:) forControlEvents:UIControlEventEditingChanged];
_textField.clearButtonMode = UITextFieldViewModeWhileEditing;
[self.contentView addSubview:_textField];
}
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
_textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:_phStr? _phStr: @"" attributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0x999999"]}];
_textField.text = _valueStr;
_textField.secureTextEntry = _isSecure;
}
- (void)configWithPlaceholder:(NSString *)phStr valueStr:(NSString *)valueStr secureTextEntry:(BOOL)isSecure{
self.phStr = phStr;
self.valueStr = valueStr;
self.isSecure = isSecure;
}
- (void)textValueChanged:(id)sender {
if (self.textValueChangedBlock) {
self.textValueChangedBlock(self.textField.text);
}
}
@end