Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6043dcb673
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 49 lines (37 sloc) 1.043 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//
// NSView+BWAdditions.m
// BWToolkit
//
// Created by Brandon Walkin (www.brandonwalkin.com)
// All code is provided under the New BSD license.
//

#import "NSView+BWAdditions.h"

NSComparisonResult compareViews(id firstView, id secondView, id context);
NSComparisonResult compareViews(id firstView, id secondView, id context)
{
  if (firstView != context && secondView != context) {return NSOrderedSame;}
  else
  {
    if (firstView == context) {return NSOrderedDescending;}
    else {return NSOrderedAscending;}
  }
}

@interface NSView (BWPrivateAdditions)
- (void)bwTurnOffLayer;
@end

@implementation NSView (BWAdditions)

- (void)bwBringToFront
{
  [[self superview] sortSubviewsUsingFunction:(NSComparisonResult (*)(id, id, void *))compareViews context:self];
}

- (id)bwAnimator
{
  float duration = [[NSAnimationContext currentContext] duration];
  [self performSelector:@selector(bwTurnOffLayer) withObject:nil afterDelay:duration];

  return [self animator];
}

- (void)bwTurnOffLayer
{
  [self setWantsLayer:NO];
}

@end


Something went wrong with that request. Please try again.