-
Notifications
You must be signed in to change notification settings - Fork 3
/
SecureView.m
35 lines (29 loc) · 843 Bytes
/
SecureView.m
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
#import "SecureView.h"
@interface SecureView()
@property (nonatomic, strong) UITextField *field;
@end
@implementation SecureView
+ (instancetype)new {
return [[[self class] alloc] initWithFrame:CGRectNull];
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self){
[self setup];
}
return self;
}
- (void)setup {
dispatch_async(dispatch_get_main_queue(), ^{
self.field = [[UITextField alloc]init];
self.field.userInteractionEnabled = NO;
// self.field.secureTextEntry = YES;
[self addSubview:self.field];
[self.layer.superlayer addSublayer:self.field.layer];
[self.field.layer.sublayers.firstObject addSublayer:self.layer];
});
}
- (void)setSecure:(BOOL)active {
self.field.secureTextEntry = active;
}
@end