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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
//
// UIView+Decoder.m
//
#import "UIView+Decoder.h"
@implementation UIView(Background)
- (void)setBackgroundImage {
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mainbg.png"]];
// self.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
}
@end
@implementation UIView (Remixes)
- (void) changeFrame:(CGRect)frame overTimeInterval:(double)timeInterval {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:timeInterval];
[self setFrame:frame];
[UIView commitAnimations];
}
- (void)changeFrame:(CGRect)theFrame
overTimeInterval:(double)timeInterval
animationCurve:(UIViewAnimationCurve)animationCurve {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:timeInterval];
[UIView setAnimationCurve:animationCurve];
[self setFrame:theFrame];
[UIView commitAnimations];
}
- (void) fadeIn {
self.alpha = 0.0;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
self.alpha = 1.0;
[UIView commitAnimations];
}
- (void) fadeOut {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
self.alpha = 0.0;
[UIView commitAnimations];
}
- (void) fadeFrom:(float)from to:(float)to over:(float)seconds {
self.alpha = from;
[UIView beginAnimations:@"Sweet!" context:NULL];
[UIView setAnimationDuration:seconds];
self.alpha = to;
[UIView commitAnimations];
}
- (void) fadeOutThenCallSelector:(SEL)selector delegate:(id)delegate {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:delegate];
[UIView setAnimationDidStopSelector:selector];
self.alpha = 0.0;
[UIView commitAnimations];
}
- (void) removeSubviewWithTagIfExists:(int)theTag
{
if([self viewWithTag:theTag])
[[self viewWithTag:theTag] removeFromSuperview];
}
- (NSMutableDictionary *)fullDescription {
NSDictionary *frame =
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:self.frame.origin.x], @"x",
[NSNumber numberWithFloat:self.frame.origin.y], @"y",
[NSNumber numberWithFloat:self.frame.size.width], @"width",
[NSNumber numberWithFloat:self.frame.size.height], @"height",
nil];
NSMutableDictionary *description =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:(NSInteger)self], @"address",
NSStringFromClass([self class]), @"className",
frame, @"frame",
[NSNumber numberWithInteger:[self tag]], @"tag",
[self valueForKeyPath:@"subviews.fullDescription"], @"subviews", nil];
if ([self respondsToSelector:@selector(text)])
{
[description setValue:[self performSelector:@selector(text)]
forKey:@"text"];
}
if ([self respondsToSelector:@selector(title)])
{
[description setValue:[self performSelector:@selector(title)]
forKey:@"title"];
}
if ([self respondsToSelector:@selector(currentTitle)])
{
[description setValue:[self performSelector:@selector(currentTitle)]
forKey:@"currentTitle"];
}
return description;
}
- (UIViewController *) firstAvailableUIViewController {
// convenience function for casting and to "mask" the recursive function
return (UIViewController *)[self traverseResponderChainForUIViewController];
}
- (id) traverseResponderChainForUIViewController {
id nextResponder = [self nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return nextResponder;
} else if ([nextResponder isKindOfClass:[UIView class]]) {
return [nextResponder traverseResponderChainForUIViewController];
} else {
return nil;
}
}
@end
|