Skip to content

Instantly share code, notes, and snippets.

@probablycorey
Created June 30, 2010 02:44
Show Gist options
  • Select an option

  • Save probablycorey/458161 to your computer and use it in GitHub Desktop.

Select an option

Save probablycorey/458161 to your computer and use it in GitHub Desktop.
waxClass{"AppDelegate", protocols = {"UIApplicationDelegate", "CAAnimationDelegate"}}
function applicationDidFinishLaunching(self, application)
local frame = UIScreen:mainScreen():bounds()
self.window = UIWindow:initWithFrame(frame)
self.window:setBackgroundColor(UIColor:orangeColor())
local label = UILabel:initWithFrame(CGRect(0, 100, 320, 40))
label:setFont(UIFont:boldSystemFontOfSize(30))
label:setColor(UIColor:orangeColor())
label:setText("Hello Lua!")
label:setTextAlignment(UITextAlignmentCenter)
local layer = label:layer()
animation = CABasicAnimation:animationWithKeyPath("opacity")
animation:setDuration(0.5)
animation:setRepeatCount(1)
animation:setAutoreverses(true)
animation:setFromValue(NSNumber:numberWithFloat(0))
animation:setToValue(NSNumber:numberWithFloat(1))
animation:setDelegate(self)
layer:addAnimation_forKey(animation, "blink")
self.window:addSubview(label)
self.window:makeKeyAndVisible()
end
function animationDidStop_finished(self, theAnimation, flag)
print("animation stopped")
end
// Many protocols will work from wax out of the box. But some need to be preloaded.
// If the protocol you are using isn't found, just add the protocol to this object
//
// This seems to be a bug, or there is a runtime method I'm unaware of
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
@protocol CAAnimationDelegate
@optional
- (void)animationDidStart:(CAAnimation *)theAnimation;
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag;
@end
@interface ProtocolLoader : NSObject <UIApplicationDelegate, UIWebViewDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UISearchBarDelegate, UITextViewDelegate, UITabBarControllerDelegate, CAAnimationDelegate> {}
@end
@implementation ProtocolLoader
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment