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
|
#import "SearchBar.h"
@implementation SearchBar
-(SearchBar *) initWithFrame: (struct CGRect) rect {
self = [super initWithFrame: rect];
bounds = rect;
[self setTextFont: @"font-family: Helvetica; font-size: 14px; padding-top: 5px; padding-left: 4px;"];
[self setAutoCapsType: 0];
[self setPreferredKeyboardType: 0];
[self setAutoCorrectionType: 1]; //disabled
[self setOpaque: 0];
[self setClearButtonStyle: 1];
//[self setPlaceholder: @"Search"];
[self setDelegate: self];
[self becomeFirstResponder];
return self;
}
- (void) show
{
[self setTransform: CGAffineTransformMake(1,0,0,1,0,0)];
[self setFrame: CGRectMake(-bounds.size.width, bounds.origin.y, bounds.size.width, bounds.size.height)];
struct CGAffineTransform trans = CGAffineTransformMakeTranslation(bounds.size.width + 10, 0);
UITransformAnimation *translate = [[UITransformAnimation alloc] initWithTarget: self];
[translate setStartTransform: CGAffineTransformMake(1,0,0,1,0,0)];
[translate setEndTransform: trans];
UIAlphaAnimation *fade = [[UIAlphaAnimation alloc] initWithTarget: self];
[fade setEndAlpha: 1];
[fade setStartAlpha: 0];
UIAnimator *animator = [[UIAnimator alloc] init];
[animator addAnimation: translate withDuration: .3 start: YES];
[animator addAnimation: fade withDuration: .3 start: YES];
}
- (void) hide
{
struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
rect.origin.x = rect.origin.y = 0;
[self setTransform: CGAffineTransformMake(1,0,0,1,0,0)];
[self setFrame: CGRectMake(0, bounds.origin.y, bounds.size.width, bounds.size.height)];
struct CGAffineTransform trans = CGAffineTransformMakeTranslation(-(bounds.size.width + 10), 0);
UITransformAnimation *translate = [[UITransformAnimation alloc] initWithTarget: self];
[translate setStartTransform: CGAffineTransformMake(1,0,0,1,0,0)];
[translate setEndTransform: trans];
UIAlphaAnimation *fade = [[UIAlphaAnimation alloc] initWithTarget: self];
[fade setEndAlpha: 0];
[fade setStartAlpha: 1];
UIAnimator *animator = [[UIAnimator alloc] init];
[animator addAnimation: translate withDuration: .3 start: YES];
[animator addAnimation: fade withDuration: .3 start: YES];
}
@end
|