Source

//// NSView+BWAdditions.m// BWToolkit//// Created by Brandon Walkin (www.brandonwalkin.com)// All code is provided under the New BSD license.//#import "NSView+BWAdditions.h"NSComparisonResultcompareViews(idfirstView,idsecondView,idcontext);NSComparisonResultcompareViews(idfirstView,idsecondView,idcontext){if(firstView!=context&&secondView!=context){returnNSOrderedSame;}else{if(firstView==context){returnNSOrderedDescending;}else{returnNSOrderedAscending;}}}@interfaceNSView(BWPrivateAdditions)-(void)bwTurnOffLayer;@end@implementationNSView(BWAdditions)-(void)bwBringToFront{[[selfsuperview]sortSubviewsUsingFunction:(NSComparisonResult(*)(id,id,void*))compareViewscontext:self];}-(id)bwAnimator{floatduration=[[NSAnimationContextcurrentContext]duration];[selfperformSelector:@selector(bwTurnOffLayer)withObject:nilafterDelay:duration];return[selfanimator];}-(void)bwTurnOffLayer{[selfsetWantsLayer:NO];}@end