Created
March 25, 2014 19:21
-
-
Save slothbear/9769200 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppDelegate | |
| def application(application, didFinishLaunchingWithOptions:launchOptions) | |
| @window = | |
| UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame) | |
| @window.makeKeyAndVisible | |
| @button = UIButton.buttonWithType(UIButtonTypeRoundedRect) | |
| @button.setTitle("start speech timer", forState:UIControlStateNormal) | |
| @button.sizeToFit | |
| @button.frame = CGRect.new( | |
| [10, @window.frame.size.height - 10 - | |
| @button.frame.size.height], | |
| @button.frame.size) | |
| @window.addSubview(@button) | |
| @button.addTarget(self, action:"vibrate", | |
| forControlEvents:UIControlEventTouchUpInside) | |
| true | |
| end | |
| def vibrate | |
| AudioServicesPlayAlertSound KSystemSoundID_Vibrate | |
| random_color = UIColor.colorWithRed(rand, green: rand, blue:rand, alpha:1) | |
| animate_to_color random_color | |
| # animate_to_color UIColor.greenColor | |
| # animate_to_color UIColor.yellowColor | |
| # animate_to_color UIColor.redColor | |
| end | |
| def animate_to_color(color) | |
| UIView.animateWithDuration(1.5, delay: 0.0, | |
| options: UIViewAnimationOptionBeginFromCurrentState, | |
| animations: lambda { | |
| @window.backgroundColor = color | |
| }, | |
| completion:lambda {|finished| | |
| }) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment