|
|
@@ -7,10 +7,15 @@
|
|
|
|
|
|
#import "ChangeLogoViewController.h"
|
|
|
#import "LogoSelectView.h"
|
|
|
+#import "iPhone.h"
|
|
|
+#import "UITextfield+NLLimit.h"
|
|
|
|
|
|
-@interface ChangeLogoViewController ()
|
|
|
+@interface ChangeLogoViewController ()<UITextFieldDelegate,LogoSelectViewDelegate>
|
|
|
{
|
|
|
LogoSelectView *logoSelectView;
|
|
|
+ UITextField *pwdTextField;
|
|
|
+ UITextField *pwdAgainTextField;
|
|
|
+ UIButton *okBtn;
|
|
|
}
|
|
|
|
|
|
@end
|
|
|
@@ -33,6 +38,7 @@
|
|
|
[self.titleLabel setText:@"更换图标"];
|
|
|
|
|
|
logoSelectView = [[LogoSelectView alloc] init];
|
|
|
+ logoSelectView.delegate = self;
|
|
|
[self.view addSubview:logoSelectView];
|
|
|
[logoSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.height.mas_equalTo(226);
|
|
|
@@ -42,7 +48,126 @@
|
|
|
}];
|
|
|
|
|
|
/*修改入口密码*/
|
|
|
+ UILabel *pwdLabel = [[UILabel alloc] init];
|
|
|
+ [pwdLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
|
|
|
+ [pwdLabel setTextColor:HW0A132BColor];
|
|
|
+ [pwdLabel setText:NSLocalizedString(@"logo_set_pwd_tips",nil)];
|
|
|
+
|
|
|
+ [self.view addSubview:pwdLabel];
|
|
|
+ [pwdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(logoSelectView.mas_bottom).offset(24.f);
|
|
|
+ make.left.mas_equalTo(16.f);
|
|
|
+ make.right.mas_equalTo(-16.f);
|
|
|
+ make.height.mas_equalTo(20.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ NSString *placeholderStr = NSLocalizedString(@"logo_input_pwd_tips",nil);
|
|
|
+ NSString *placeholderStr1 = NSLocalizedString(@"logo_input_pwd_again_tips",nil);
|
|
|
+ CGFloat fontSize = 13.f;
|
|
|
+ CGFloat textfontSize = 16.f;
|
|
|
+ CGFloat inputTextFieldH = 48.f;
|
|
|
+ NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
|
|
+ style.alignment = NSTextAlignmentLeft;
|
|
|
+
|
|
|
+ NSAttributedString *attri = nil;
|
|
|
+ NSAttributedString *attri1 = nil;
|
|
|
+ NSString *verphone = [iPhone phoneVersion];
|
|
|
+
|
|
|
+ if ([verphone isEqualToString:@"10.3.3"]){
|
|
|
+ attri = [[NSAttributedString alloc] initWithString:placeholderStr
|
|
|
+ attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
|
|
|
+ NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
|
|
|
+ NSBaselineOffsetAttributeName:[NSNumber numberWithFloat:-1.5],
|
|
|
+ NSParagraphStyleAttributeName:style}];
|
|
|
+ attri1 = [[NSAttributedString alloc] initWithString:placeholderStr1
|
|
|
+ attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
|
|
|
+ NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
|
|
|
+ NSBaselineOffsetAttributeName:[NSNumber numberWithFloat:-1.5],
|
|
|
+ NSParagraphStyleAttributeName:style}];
|
|
|
+ }else{
|
|
|
+ attri = [[NSAttributedString alloc] initWithString:placeholderStr
|
|
|
+ attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
|
|
|
+ NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
|
|
|
+ NSParagraphStyleAttributeName:style}];
|
|
|
+ attri1 = [[NSAttributedString alloc] initWithString:placeholderStr1
|
|
|
+ attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
|
|
|
+ NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
|
|
|
+ NSBaselineOffsetAttributeName:[NSNumber numberWithFloat:-1.5],
|
|
|
+ NSParagraphStyleAttributeName:style}];
|
|
|
+ }
|
|
|
+
|
|
|
+ pwdTextField = [[UITextField alloc] init];
|
|
|
+ pwdTextField.delegate = self;
|
|
|
+ [pwdTextField setNl_maxLength:4];
|
|
|
+ [pwdTextField setKeyboardType:(UIKeyboardTypeNumberPad)];
|
|
|
+ [self.view addSubview:pwdTextField];
|
|
|
+ [pwdTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(pwdLabel.mas_bottom).offset(12.f);
|
|
|
+ make.left.mas_equalTo(16.f);
|
|
|
+ make.right.mas_equalTo(-16.f);
|
|
|
+ make.height.mas_equalTo(inputTextFieldH);
|
|
|
+ }];
|
|
|
+ pwdTextField.attributedPlaceholder = attri;
|
|
|
+ pwdTextField.layer.cornerRadius = 8.f;
|
|
|
+ [pwdTextField setFont:[UIFont systemFontOfSize:textfontSize]];
|
|
|
+ [pwdTextField setTextColor:HW0A132BColor];
|
|
|
+ [pwdTextField setBackgroundColor:[UIColor whiteColor]];
|
|
|
+ UIView *leftView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, 15, inputTextFieldH))];
|
|
|
+ [leftView setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [pwdTextField setLeftView:leftView];
|
|
|
+ [pwdTextField setLeftViewMode:(UITextFieldViewModeAlways)];
|
|
|
|
|
|
+ pwdAgainTextField = [[UITextField alloc] init];
|
|
|
+ pwdAgainTextField.delegate = self;
|
|
|
+ [pwdAgainTextField setNl_maxLength:4];
|
|
|
+ [pwdAgainTextField setKeyboardType:(UIKeyboardTypeNumberPad)];
|
|
|
+ [self.view addSubview:pwdAgainTextField];
|
|
|
+ [pwdAgainTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(pwdTextField.mas_bottom).offset(15.f);
|
|
|
+ make.left.mas_equalTo(16.f);
|
|
|
+ make.right.mas_equalTo(-16.f);
|
|
|
+ make.height.mas_equalTo(inputTextFieldH);
|
|
|
+ }];
|
|
|
+ pwdAgainTextField.attributedPlaceholder = attri1;
|
|
|
+ pwdAgainTextField.layer.cornerRadius = 8.f;
|
|
|
+ [pwdAgainTextField setFont:[UIFont systemFontOfSize:textfontSize]];
|
|
|
+ [pwdAgainTextField setTextColor:HW0A132BColor];
|
|
|
+ [pwdAgainTextField setBackgroundColor:[UIColor whiteColor]];
|
|
|
+ UIView *leftView1 = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, 15, inputTextFieldH))];
|
|
|
+ [leftView1 setBackgroundColor:[UIColor clearColor]];
|
|
|
+ [pwdAgainTextField setLeftView:leftView1];
|
|
|
+ [pwdAgainTextField setLeftViewMode:(UITextFieldViewModeAlways)];
|
|
|
+
|
|
|
+ /*确认按钮*/
|
|
|
+ okBtn = [[UIButton alloc] init];
|
|
|
+ CGFloat okBtn_W = SCREEN_W - 2*16.f;
|
|
|
+
|
|
|
+ // gradient
|
|
|
+ CAGradientLayer *gl = [CAGradientLayer layer];
|
|
|
+ gl.frame = CGRectMake(0,0,okBtn_W,48);
|
|
|
+ gl.startPoint = CGPointMake(0, 0.5);
|
|
|
+ gl.endPoint = CGPointMake(1, 0.5);
|
|
|
+ gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
|
|
|
+ gl.locations = @[@(0), @(1.0f)];
|
|
|
+ okBtn.layer.cornerRadius = 8;
|
|
|
+ okBtn.clipsToBounds = YES;
|
|
|
+ [okBtn.layer addSublayer:gl];
|
|
|
+ [okBtn setTitle:NSLocalizedString(@"other_confirm",nil) forState:(UIControlStateNormal)];
|
|
|
+ [okBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
|
|
+ [okBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
|
|
|
+ [self.view addSubview:okBtn];
|
|
|
+ [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(pwdAgainTextField.mas_bottom).offset(16.f);
|
|
|
+ make.centerX.equalTo(self.view.mas_centerX);
|
|
|
+ make.width.mas_equalTo(okBtn_W);
|
|
|
+ make.height.mas_equalTo(48);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [okBtn addTarget:self
|
|
|
+ action:@selector(okBtnPressed)
|
|
|
+ forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
+ [okBtn setEnabled:NO];
|
|
|
+ [okBtn setAlpha:0.5];
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -55,4 +180,90 @@
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
|
|
+{
|
|
|
+ if (textField == pwdAgainTextField || textField == pwdTextField)
|
|
|
+ {
|
|
|
+ /*特定字符限制*/
|
|
|
+ NSCharacterSet *cs;
|
|
|
+ cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"]invertedSet];
|
|
|
+ NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];//按cs分离出数组,数组按@""分离出字符串
|
|
|
+
|
|
|
+ BOOL canChange = [string isEqualToString:filtered];
|
|
|
+
|
|
|
+ if (logoSelectView.selectIndex <= 0){
|
|
|
+ if ([pwdAgainTextField.text isEqualToString:@""]
|
|
|
+ || pwdAgainTextField.text == nil
|
|
|
+ || [pwdTextField.text isEqualToString:@""]
|
|
|
+ || pwdTextField.text == nil)
|
|
|
+ {
|
|
|
+ [okBtn setEnabled:NO];
|
|
|
+ [okBtn setAlpha:0.5];
|
|
|
+ }else{
|
|
|
+ [okBtn setEnabled:YES];
|
|
|
+ [okBtn setAlpha:1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return canChange;
|
|
|
+ }
|
|
|
+ return YES;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)okBtnPressed{
|
|
|
+ if (pwdTextField.text.length > 0 || pwdAgainTextField.text.length > 0){
|
|
|
+ if (![pwdTextField.text isEqualToString:pwdAgainTextField.text] || pwdAgainTextField.text.length != 4 ){
|
|
|
+ [[iToast makeText:NSLocalizedString(@"logo_input_pwd_no_same_tips",nil)] show];
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ /*设置密码*/
|
|
|
+ NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
|
|
|
+ [pwdAgainTextField.text writeToFile:launchAppPWDPath atomically:YES];
|
|
|
+
|
|
|
+ [[iToast makeText:NSLocalizedString(@"logo_set_pwd_success",nil)] show];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (logoSelectView.selectIndex == 1){
|
|
|
+ /*设置图标*/
|
|
|
+ [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon 1" completionHandler:^(NSError * _Nullable error) {}];
|
|
|
+ }else if (logoSelectView.selectIndex == 2){
|
|
|
+ /*设置图标*/
|
|
|
+ [[UIApplication sharedApplication] setAlternateIconName:@"AppIcon 2" completionHandler:^(NSError * _Nullable error) {}];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)logoSelectViewHaveSelect{
|
|
|
+ [okBtn setEnabled:YES];
|
|
|
+ [okBtn setAlpha:1];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
|
|
+ [[UIApplication sharedApplication].keyWindow endEditing:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
|
|
|
+
|
|
|
+ NSString *path = DocumentPath;
|
|
|
+ if (account.length != 0) {
|
|
|
+ path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([fileFolder containsString:@"/"]) {
|
|
|
+ NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
|
|
|
+ path1 = [path1 stringByDeletingLastPathComponent];
|
|
|
+ NSError *error;
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
|
|
|
+ [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ NSError *error;
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
|
|
+ [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [path stringByAppendingPathComponent:fileFolder];
|
|
|
+}
|
|
|
+
|
|
|
@end
|