Permalink
Browse files

Signed-off-by: Brandon Emrich <brandon@zueos.com>

  • Loading branch information...
1 parent 5084e65 commit dc794b1fc811147c1ec6c60dee021ada40105fe9 @brandonemrich brandonemrich committed Aug 11, 2010
Showing with 3,760 additions and 0 deletions.
  1. +34 −0 Classes/ZIStoreButton.h
  2. +191 −0 Classes/ZIStoreButton.m
  3. +39 −0 Classes/ZIStoreButtonDemoAppDelegate.h
  4. +106 −0 Classes/ZIStoreButtonDemoAppDelegate.m
  5. +36 −0 Classes/ZIStoreButtonDemoViewController.h
  6. +118 −0 Classes/ZIStoreButtonDemoViewController.m
  7. +444 −0 MainWindow.xib
  8. +1 −0 README
  9. +30 −0 ZIStoreButtonDemo-Info.plist
  10. +1,405 −0 ZIStoreButtonDemo.xcodeproj/brandon.mode1v3
  11. +259 −0 ZIStoreButtonDemo.xcodeproj/brandon.pbxuser
  12. +261 −0 ZIStoreButtonDemo.xcodeproj/project.pbxproj
  13. +156 −0 ZIStoreButtonDemoViewController.xib
  14. +8 −0 ZIStoreButtonDemo_Prefix.pch
  15. +18 −0 build/Debug-iphonesimulator/ZIStoreButtonDemo.app.dSYM/Contents/Info.plist
  16. BIN build/Debug-iphonesimulator/ZIStoreButtonDemo.app.dSYM/Contents/Resources/DWARF/ZIStoreButtonDemo
  17. BIN build/Debug-iphonesimulator/ZIStoreButtonDemo.app/Info.plist
  18. BIN build/Debug-iphonesimulator/ZIStoreButtonDemo.app/MainWindow.nib
  19. +1 −0 build/Debug-iphonesimulator/ZIStoreButtonDemo.app/PkgInfo
  20. BIN build/Debug-iphonesimulator/ZIStoreButtonDemo.app/ZIStoreButtonDemo
  21. BIN build/Debug-iphonesimulator/ZIStoreButtonDemo.app/ZIStoreButtonDemoViewController.nib
  22. BIN ...uttonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButton.o
  23. BIN ...tonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButton.o~$
  24. 0 ...tonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButton.o~>
  25. BIN ...tonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButton.o~?
  26. +4 −0 .../Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemo.LinkFileList
  27. BIN .../Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoAppDelegate.o
  28. BIN ...ebug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoAppDelegate.o~$
  29. 0 ...ebug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoAppDelegate.o~>
  30. BIN ...bug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoViewController.o
  31. BIN ...g-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoViewController.o~$
  32. 0 ...g-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/ZIStoreButtonDemoViewController.o~>
  33. BIN .../ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/Objects-normal/i386/main.o
  34. BIN ...emo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo-all-target-headers.hmap
  35. BIN ...onDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo-generated-files.hmap
  36. BIN ...emo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo-own-target-headers.hmap
  37. BIN ...onDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo-project-headers.hmap
  38. +12 −0 build/ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo.dep
  39. BIN build/ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo.hmap
  40. +12 −0 build/ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/ZIStoreButtonDemo~.dep
  41. +300 −0 build/ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/build-state.dat
  42. +308 −0 build/ZIStoreButtonDemo.build/Debug-iphonesimulator/ZIStoreButtonDemo.build/build-state~.dat
  43. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/categories.pbxbtree
  44. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/cdecls.pbxbtree
  45. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/decls.pbxbtree
  46. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/files.pbxbtree
  47. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/imports.pbxbtree
  48. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/pbxindex.header
  49. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/protocols.pbxbtree
  50. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/refs.pbxbtree
  51. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/strings.pbxstrings/control
  52. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/strings.pbxstrings/strings
  53. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/subclasses.pbxbtree
  54. BIN build/ZIStoreButtonDemo.build/ZIStoreButtonDemo.pbxindex/symbols0.pbxsymbols
  55. +17 −0 main.m
View
@@ -0,0 +1,34 @@
+//
+// ZIStoreButton.h
+// ZIStoreButtonDemo
+//
+// Created by Brandon Emrich on 7/20/10.
+// Copyright 2010 Zueos, Inc. All rights reserved.
+//
+
+/*
+// Copyright 2010 Brandon Emrich
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#import <UIKit/UIKit.h>
+#import <QuartzCore/QuartzCore.h>
+
+@interface ZIStoreButton : UIButton
+{
+ CAGradientLayer *innerLayer3;
+ BOOL isBlued;
+}
+
+@end
View
@@ -0,0 +1,191 @@
+//
+// ZIStoreButton.m
+// ZIStoreButtonDemo
+//
+// Created by Brandon Emrich on 7/20/10.
+// Copyright 2010 Zueos, Inc. All rights reserved.
+//
+
+/*
+// Copyright 2010 Brandon Emrich
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#import "ZIStoreButton.h"
+
+@implementation ZIStoreButton
+
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ // Initialization code
+
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+
+ self.autoresizesSubviews = YES;
+ self.layer.needsDisplayOnBoundsChange = YES;
+
+ isBlued = NO;
+
+ [self setTitle:@"Purchase Now" forState:UIControlStateSelected];
+ [self setTitleShadowColor:[UIColor colorWithWhite:0.200 alpha:1.000] forState:UIControlStateNormal];
+ [self setTitleShadowColor:[UIColor colorWithWhite:0.200 alpha:1.000] forState:UIControlStateSelected];
+ [self.titleLabel setShadowOffset:CGSizeMake(0.0, -0.6)];
+ [self.titleLabel setFont:[UIFont boldSystemFontOfSize:12.0]];
+ self.titleLabel.textColor = [UIColor colorWithWhite:0.902 alpha:1.000];
+ self.titleEdgeInsets = UIEdgeInsetsMake(2.0, 0.0, 0.0, 0.0);
+
+ [self addTarget:self action:@selector(touchedUpOutside:) forControlEvents:UIControlEventTouchUpOutside];
+ [self addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
+
+ CAGradientLayer *bevelLayer2 = [CAGradientLayer layer];
+ bevelLayer2.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithWhite:0.4 alpha:1.0] CGColor], [[UIColor whiteColor] CGColor], nil];
+ bevelLayer2.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame));
+ bevelLayer2.cornerRadius = 5.0;
+ bevelLayer2.needsDisplayOnBoundsChange = YES;
+
+ CAGradientLayer *innerLayer2 = [CAGradientLayer layer];
+ innerLayer2.colors = [NSArray arrayWithObjects:(id)[[UIColor darkGrayColor] CGColor], [[UIColor lightGrayColor] CGColor], nil];
+ innerLayer2.frame = CGRectMake(0.5, 0.5, CGRectGetWidth(frame) - 1.0, CGRectGetHeight(frame) - 1.0);
+ innerLayer2.cornerRadius = 4.6;
+ innerLayer2.needsDisplayOnBoundsChange = YES;
+
+ UIColor *blueOne = [UIColor colorWithRed:0.306 green:0.380 blue:0.547 alpha:1.000];
+ UIColor *blueTwo = [UIColor colorWithRed:0.258 green:0.307 blue:0.402 alpha:1.000];
+ UIColor *blueThree = [UIColor colorWithRed:0.159 green:0.270 blue:0.550 alpha:1.000];
+ UIColor *blueFour = [UIColor colorWithRed:0.129 green:0.220 blue:0.452 alpha:1.000];
+
+ NSArray *blueColors = [NSArray arrayWithObjects:(id)blueOne.CGColor, blueTwo.CGColor, blueThree.CGColor, blueFour.CGColor, nil];
+
+ innerLayer3 = [CAGradientLayer layer];
+ innerLayer3.colors = blueColors;
+ innerLayer3.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:0.500], [NSNumber numberWithFloat:0.5001], [NSNumber numberWithFloat:1.0], nil];
+ innerLayer3.frame = CGRectMake(0.75, 0.75, CGRectGetWidth(frame) - 1.5, CGRectGetHeight(frame) - 1.5);
+ innerLayer3.cornerRadius = 4.5;
+ innerLayer3.needsDisplayOnBoundsChange = YES;
+
+ [self.layer addSublayer:bevelLayer2];
+ [self.layer addSublayer:innerLayer2];
+ [self.layer addSublayer:innerLayer3];
+
+ [self bringSubviewToFront:self.titleLabel];
+
+ }
+ return self;
+}
+
+
+- (void) setSelected:(BOOL)selected {
+
+ [super setSelected:selected];
+
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:0.25];
+
+
+
+ UIColor *blueOne = [UIColor colorWithRed:0.306 green:0.380 blue:0.547 alpha:1.000];
+ UIColor *blueTwo = [UIColor colorWithRed:0.258 green:0.307 blue:0.402 alpha:1.000];
+ UIColor *blueThree = [UIColor colorWithRed:0.159 green:0.270 blue:0.550 alpha:1.000];
+ UIColor *blueFour = [UIColor colorWithRed:0.129 green:0.220 blue:0.452 alpha:1.000];
+
+ NSArray *blueColors = [NSArray arrayWithObjects:(id)blueOne.CGColor, blueTwo.CGColor, blueThree.CGColor, blueFour.CGColor, nil];
+ NSArray *greenColors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.482 green:0.674 blue:0.406 alpha:1.000] CGColor], [[UIColor colorWithRed:0.525 green:0.742 blue:0.454 alpha:1.000] CGColor], [[UIColor colorWithRed:0.346 green:0.719 blue:0.183 alpha:1.000] CGColor], [[UIColor colorWithRed:0.299 green:0.606 blue:0.163 alpha:1.000] CGColor], nil];
+
+ if (!selected) {
+
+ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"colors"];
+ animation.fromValue = greenColors;
+ animation.toValue = blueColors;
+ animation.duration = 0.25;
+ animation.removedOnCompletion = NO;
+ animation.fillMode = kCAFillModeForwards;
+ animation.delegate = self;
+
+ [innerLayer3 layoutIfNeeded];
+ [innerLayer3 addAnimation:animation forKey:@"changeToBlue"];
+
+ for (CALayer *la in self.layer.sublayers) {
+ CGRect cr = la.bounds;
+ cr.size.width -= 50.0;
+ la.bounds = cr;
+ [la layoutIfNeeded];
+ }
+
+ CGRect cr = self.frame;
+ cr.size.width -= 50.0;
+ self.frame = cr;
+
+ self.titleEdgeInsets = UIEdgeInsetsMake(2.0, 0.0, 0.0, 0.0);
+
+ } else {
+
+ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"colors"];
+ animation.toValue = greenColors;
+ animation.fromValue = blueColors;
+ animation.duration = 0.25;
+ animation.removedOnCompletion = NO;
+ animation.fillMode = kCAFillModeForwards;
+
+ [innerLayer3 layoutIfNeeded];
+ [innerLayer3 addAnimation:animation forKey:@"changeToGreen"];
+
+ for (CALayer *la in self.layer.sublayers) {
+ CGRect cr = la.bounds;
+ cr.size.width += 50.0;
+ la.bounds = cr;
+ [la layoutIfNeeded];
+ }
+
+ CGRect cr = self.frame;
+ cr.size.width += 50.0;
+ self.frame = cr;
+
+ self.titleEdgeInsets = UIEdgeInsetsMake(2.0, -50.0, 0.0, 0.0);
+
+ }
+}
+
+
+- (IBAction) touchedUpOutside:(id)sender {
+ if (self.selected) {
+ [self setSelected:NO];
+ }
+}
+
+
+- (IBAction) pressButton:(id)sender {
+ if (isBlued) {
+ [sender setSelected:NO];
+ isBlued = NO;
+ } else {
+ [sender setSelected:YES];
+ isBlued = YES;
+ }
+}
+
+
+- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
+
+ NSLog(@"Animation Did Stop");
+
+}
+
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+
+@end
@@ -0,0 +1,39 @@
+//
+// ZIStoreButtonDemoAppDelegate.h
+// ZIStoreButtonDemo
+//
+// Created by Brandon Emrich on 7/20/10.
+// Copyright Zueos, Inc. 2010. All rights reserved.
+//
+
+/*
+// Copyright 2010 Brandon Emrich
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#import <UIKit/UIKit.h>
+
+@class ZIStoreButtonDemoViewController;
+
+@interface ZIStoreButtonDemoAppDelegate : NSObject <UIApplicationDelegate>
+{
+ UIWindow *window;
+ ZIStoreButtonDemoViewController *viewController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet ZIStoreButtonDemoViewController *viewController;
+
+@end
+
@@ -0,0 +1,106 @@
+//
+// ZIStoreButtonDemoAppDelegate.m
+// ZIStoreButtonDemo
+//
+// Created by Brandon Emrich on 7/20/10.
+// Copyright Zueos, Inc. 2010. All rights reserved.
+//
+
+/*
+// Copyright 2010 Brandon Emrich
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#import "ZIStoreButtonDemoAppDelegate.h"
+#import "ZIStoreButtonDemoViewController.h"
+
+@implementation ZIStoreButtonDemoAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
+ // Override point for customization after application launch.
+
+ // Add the view controller's view to the window and display.
+ [window addSubview:viewController.view];
+ [window makeKeyAndVisible];
+
+ return YES;
+}
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ */
+}
+
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
+ */
+}
+
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ /*
+ Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
+ */
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ */
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ /*
+ Called when the application is about to terminate.
+ See also applicationDidEnterBackground:.
+ */
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ /*
+ Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
+ */
+}
+
+
+- (void)dealloc {
+ [viewController release];
+ [window release];
+ [super dealloc];
+}
+
+
+@end
Oops, something went wrong.

0 comments on commit dc794b1

Please sign in to comment.