Skip to content

Instantly share code, notes, and snippets.

@slothbear
Created March 25, 2014 19:21
Show Gist options
  • Select an option

  • Save slothbear/9769200 to your computer and use it in GitHub Desktop.

Select an option

Save slothbear/9769200 to your computer and use it in GitHub Desktop.
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