Skip to content

Commit 6c40254

Browse files
committed
调整 <高级设置> 删除项目密码Alert样式
1 parent a0a4feb commit 6c40254

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

Coding_iOS/Controllers/ProjectSetting/ProjectAdvancedSettingViewController.m

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#import "Coding_NetAPIManager.h"
1111

1212
#import <SDCAlertController.h>
13+
#import <SDCAlertView.h>
14+
#import <UIView+SDCAutoLayout.h>
1315
#import "ProjectDeleteAlertControllerVisualStyle.h"
1416

1517
@interface ProjectAdvancedSettingViewController ()
@@ -21,6 +23,7 @@ @implementation ProjectAdvancedSettingViewController
2123
- (void)viewDidLoad {
2224
[super viewDidLoad];
2325

26+
self.title = @"高级设置";
2427
self.tableView.tableFooterView = [UIView new];
2528
}
2629

@@ -60,24 +63,38 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
6063

6164
SDCAlertController *alert = [SDCAlertController alertControllerWithTitle:title message:message preferredStyle:SDCAlertControllerStyleAlert];
6265

66+
UITextField *passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(15, 0, 240.0, 30.0)];
67+
passwordTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 30)];
68+
passwordTextField.leftViewMode = UITextFieldViewModeAlways;
69+
passwordTextField.layer.borderColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.6].CGColor;
70+
passwordTextField.layer.borderWidth = 1;
71+
passwordTextField.secureTextEntry = YES;
72+
passwordTextField.backgroundColor = [UIColor whiteColor];
73+
74+
[alert.contentView addSubview:passwordTextField];
75+
76+
NSDictionary* passwordViews = NSDictionaryOfVariableBindings(passwordTextField);
77+
78+
[alert.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[passwordTextField]-(>=14)-|" options:0 metrics:nil views:passwordViews]];
79+
80+
[passwordTextField becomeFirstResponder];
81+
6382
// Style
6483
alert.visualStyle = [ProjectDeleteAlertControllerVisualStyle new];
6584

6685
// 添加密码框
67-
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
68-
textField.secureTextEntry = YES;
69-
}];
86+
// [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
87+
// textField.secureTextEntry = YES;
88+
// }];
7089

7190
// 添加按钮
7291
alert.actionLayout = SDCAlertControllerActionLayoutHorizontal;
73-
[alert addAction:[SDCAlertAction actionWithTitle:@"取消" style:SDCAlertActionStyleCancel handler:^(SDCAlertAction *action) {
74-
[alert dismissWithCompletion:nil];
75-
}]];
92+
[alert addAction:[SDCAlertAction actionWithTitle:@"取消" style:SDCAlertActionStyleDefault handler:nil]];
7693
[alert addAction:[SDCAlertAction actionWithTitle:@"确定" style:SDCAlertActionStyleDefault handler:^(SDCAlertAction *action) {
77-
UITextField *passwordTextField = [[alert textFields] firstObject];
94+
7895
NSString *password = [passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
7996

80-
if (password > 0) {
97+
if ([password length] > 0) {
8198
// 删除项目
8299
[[Coding_NetAPIManager sharedManager] request_DeleteProject_WithObj:self.project password:password andBlock:^(Project *data, NSError *error) {
83100
if (!error) {
@@ -87,7 +104,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
87104
}];
88105
}
89106
}]];
90-
107+
91108
[alert presentWithCompletion:nil];
92109
}
93110

Coding_iOS/Controllers/ProjectSetting/ProjectDeleteAlertControllerVisualStyle.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
@implementation ProjectDeleteAlertControllerVisualStyle
1212

13+
- (CGFloat)labelSpacing {
14+
return 30;
15+
}
16+
1317
-(UIColor *)titleLabelColor{
1418
return [UIColor colorWithRGBHex:0x222222];
1519
}
@@ -18,12 +22,16 @@ -(UIColor *)messageLabelColor{
1822
return [UIColor colorWithRGBHex:0xf34a4a];
1923
}
2024

21-
- (CGFloat)labelSpacing {
22-
return 30;
25+
- (CGFloat)messageLabelBottomSpacing {
26+
return 14;
2327
}
2428

25-
- (CGFloat)messageLabelBottomSpacing {
26-
return 20;
29+
-(UIFont *)titleLabelFont{
30+
return [UIFont boldSystemFontOfSize:17.0];
31+
}
32+
33+
-(UIFont *)messageLabelFont{
34+
return [UIFont boldSystemFontOfSize:14.0];
2735
}
2836

2937
@end

0 commit comments

Comments
 (0)