forked from wfxiaolong/STWebViewController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTAlertView.m
More file actions
76 lines (58 loc) · 2.86 KB
/
STAlertView.m
File metadata and controls
76 lines (58 loc) · 2.86 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// STAlertView.m
// STWebViewController
//
// Created by linxiaolong on 15/5/15.
// Copyright (c) 2015年 linxiaolong. All rights reserved.
//
#import "STAlertView.h"
@interface STAlertView () <UITextFieldDelegate>
@property (nonatomic, strong) UITextField *hostField;
@property (nonatomic, strong) UITextField *ipAddressField;
@property (nonatomic, strong) UIButton *comfirmBtn;
@property (nonatomic, copy ) TouchBlock tMBlock;
@end
@implementation STAlertView
- (void)mainTitle:(NSString *)mtitle block:(TouchBlock)block {
CGRect mainRect = [UIScreen mainScreen].bounds;
CGFloat wlength = 960/16*5-30;
CGFloat hlength = 696/16*5-25;
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(mainRect.size.width/2-wlength/2, mainRect.size.height/2-hlength/2 - 100, wlength, hlength)];
contentView.backgroundColor = [UIColor whiteColor];
// set subView
UILabel *mainLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, wlength-25, 20)];
mainLable.textColor = [UIColor orangeColor];
mainLable.text = mtitle;
[contentView addSubview:mainLable];
UILabel *lineLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, wlength-25, 0.5)];
lineLable.backgroundColor = [UIColor colorWithRed:249.0/255 green:157.0/255 blue:59.0/255 alpha:1];
[contentView addSubview:lineLable];
// add textField
self.hostField = [[UITextField alloc] initWithFrame:CGRectMake(-1, 50, wlength+2, 30)];
self.hostField.layer.borderWidth = 1;
self.hostField.layer.borderColor = [UIColor grayColor].CGColor;
self.hostField.textAlignment = NSTextAlignmentCenter;
self.hostField.placeholder = @"例如:www.github.com ";
self.ipAddressField = [[UITextField alloc] initWithFrame:CGRectMake(-1, 79, wlength+2, 30)];
self.ipAddressField.layer.borderWidth = 1;
self.ipAddressField.layer.borderColor = [UIColor grayColor].CGColor;
self.ipAddressField.textAlignment = NSTextAlignmentCenter;
self.ipAddressField.placeholder = @"例如:181.12.1.111 ";
[contentView addSubview:self.ipAddressField];
[contentView addSubview:self.hostField];
// add comfirm btn
self.comfirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 150, wlength, 30)];
self.comfirmBtn.backgroundColor = [UIColor blackColor];
[self.comfirmBtn setTitle:@"添加" forState:UIControlStateNormal];
self.tMBlock = block;
[contentView addSubview:self.comfirmBtn];
[self.comfirmBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
contentView.layer.cornerRadius = 4;
contentView.alpha = 0.9;
[FVCustomAlertView content:contentView backAlpha:0.5 touchClose:YES];
}
- (void)btnClick:(id)sender {
NSLog(@"我要去冲浪。。。🏄🏄🏄...");
self.tMBlock(self.hostField.text, self.ipAddressField.text);
}
@end