-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathURLTextView.m
More file actions
executable file
·95 lines (73 loc) · 4.25 KB
/
URLTextView.m
File metadata and controls
executable file
·95 lines (73 loc) · 4.25 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#import "URLTextView.h"
@implementation URLTextView
- (id)initWithCoder:(NSCoder *)aDecoder{
self=[super initWithCoder:aDecoder];
if(self){
UIView*aView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
aView.backgroundColor=SECTIONCOLOR;
UIButton *httpButton = [[UIButton alloc]initWithFrame:CGRectMake(10, 0, (SCREEN_WIDTH-40)/4, 40)];
[httpButton setTitle:@"http://" forState:UIControlStateNormal];
[httpButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[httpButton addTarget:self action:@selector(addHttp) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:httpButton];
UIButton *wwwButton = [[UIButton alloc]initWithFrame:CGRectMake(20+(SCREEN_WIDTH-40)/4, 0, (SCREEN_WIDTH-40)/3, 40)];
[wwwButton setTitle:@"www." forState:UIControlStateNormal];
[wwwButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[wwwButton addTarget:self action:@selector(addwww) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:wwwButton];
UIButton *comButton = [[UIButton alloc]initWithFrame:CGRectMake(30+2*(SCREEN_WIDTH-40)/4, 0, (SCREEN_WIDTH-40)/3, 40)];
[comButton setTitle:@".com" forState:UIControlStateNormal];
[comButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[comButton addTarget:self action:@selector(addcom) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:comButton];
UIButton *cnButton = [[UIButton alloc]initWithFrame:CGRectMake(40+3*(SCREEN_WIDTH-40)/4, 0, (SCREEN_WIDTH-40)/3, 40)];
[cnButton setTitle:@".cn" forState:UIControlStateNormal];
[cnButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[cnButton addTarget:self action:@selector(addcn) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:cnButton];
self.inputAccessoryView=aView;
}
return self;
}
-(id)init{
self=[super init];
if(self){
UIView*aView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
aView.backgroundColor=SECTIONCOLOR;
UIButton *httpButton = [[UIButton alloc]initWithFrame:CGRectMake(10, 5, (SCREEN_WIDTH-40)/4, 40)];
[httpButton setTitle:@"http://" forState:UIControlStateNormal];
[httpButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[httpButton addTarget:self action:@selector(addHttp) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:httpButton];
UIButton *wwwButton = [[UIButton alloc]initWithFrame:CGRectMake(20+(SCREEN_WIDTH-40)/4, 5, (SCREEN_WIDTH-40)/3, 40)];
[wwwButton setTitle:@"www." forState:UIControlStateNormal];
[wwwButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[wwwButton addTarget:self action:@selector(addwww) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:wwwButton];
UIButton *comButton = [[UIButton alloc]initWithFrame:CGRectMake(30+2*(SCREEN_WIDTH-40)/4, 5, (SCREEN_WIDTH-40)/3, 40)];
[comButton setTitle:@".com" forState:UIControlStateNormal];
[comButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[comButton addTarget:self action:@selector(addcom) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:comButton];
UIButton *cnButton = [[UIButton alloc]initWithFrame:CGRectMake(40+3*(SCREEN_WIDTH-40)/4, 5, (SCREEN_WIDTH-40)/3, 40)];
[cnButton setTitle:@".cn" forState:UIControlStateNormal];
[cnButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[cnButton addTarget:self action:@selector(addcn) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:cnButton];
self.inputAccessoryView=aView;
}
return self;
}
- (void)addHttp{
self.text = @"http://";
}
- (void)addwww{
self.text = [self.text stringByAppendingString:@"www."];
}
- (void)addcom{
self.text = [self.text stringByAppendingString:@".com"];
}
- (void)addcn{
self.text = [self.text stringByAppendingString:@".cn"];
}
@end