Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AppKit for UIKit developers

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

AppKit for UIKit developers

Avatar for Florian Kugler

Florian Kugler

October 05, 2014
Tweet

More Decks by Florian Kugler

Other Decks in Programming

Transcript

  1. WINDOWS @interface MyWindowController : NSWindowController @end @implementation MyWindowController - (instancetype)init

    { return [super initWithWindowNibName:@"MyWindow"]; } @end #Pragma'Conference'2014
  2. @implementation ColoredView - (BOOL)wantsUpdateLayer { return YES; } - (void)updateLayer

    { self.layer.backgroundColor = self.backgroundColor.CGColor; } - (void)setBackgroundColor:(NSColor *)backgroundColor { _backgroundColor = backgroundColor; [self setNeedsDisplay:YES]; } @end #Pragma'Conference'2014
  3. - (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) {

    self.layer = [[CALayer alloc] init]; self.wantsLayer = YES; } } #Pragma'Conference'2014
  4. ANIMATION'CONTEXT [NSAnimationContext runAnimationGroup:^(NSAnimationContext *ctx){ ctx.duration = 1; ctx.timingFunction = [CAMediaTimingFunction

    functionWithName:kCAMediaTimingFunctionEaseIn]; view.animator.alphaValue = .5; } completionHandler:^{ // ... }]; #Pragma'Conference'2014
  5. CORE%ANIMATION CAKeyframeAnimation *animation = [CAKeyframeAnimation animation]; animation.values = @[@1, @.9,

    @.8, @.7, @.6]; view.animations = @{@"alphaValue": animation}; view.animator.alphaValue = .5; #Pragma'Conference'2014