summaryrefslogtreecommitdiff
path: root/Volta/Additions/UIView+Decoder.m
diff options
context:
space:
mode:
authorRonny Fenrich <Fenrich@Gmail.com>2013-06-13 13:40:44 -0600
committerRonny Fenrich <Fenrich@Gmail.com>2013-06-13 13:40:44 -0600
commitbf6c97cdee2264656211126ee01066c3c5d4bd8d (patch)
treedf4a6a9ed1b76109a57d1bf71c85b5632a6e3a0b /Volta/Additions/UIView+Decoder.m
parentd6d01c9dd86561ad2121f0f85f0a4529142d5093 (diff)
added Xcode project and converted to CocoaPods (added a bunch of libraries)
Diffstat (limited to 'Volta/Additions/UIView+Decoder.m')
-rw-r--r--Volta/Additions/UIView+Decoder.m135
1 files changed, 135 insertions, 0 deletions
diff --git a/Volta/Additions/UIView+Decoder.m b/Volta/Additions/UIView+Decoder.m
new file mode 100644
index 0000000..0ff029b
--- /dev/null
+++ b/Volta/Additions/UIView+Decoder.m
@@ -0,0 +1,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
+
+
+