Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Willing jwilling

View GitHub Profile
@jwilling
jwilling / gist:8160367
Created Dec 28, 2013
NSViewLayerContentsRedrawCrossfade on 10.8
View gist:8160367
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
context.duration = 4.f;
context.allowsImplicitAnimation = YES;
[view.layer addAnimation:CATransition.animation forKey:@"contents"];
view.layer.contents = someImage;
} completionHandler:nil];
@jwilling
jwilling / LBHView.h
Last active Feb 6, 2018
A terrible, terrible hack to toggle AppKit's destruction of layer modifications.
View LBHView.h
#import <Cocoa/Cocoa.h>
@interface LBHView : NSView
/// This property controls whether the view can indirectly control its
/// backing layer's properties, specifically the following:
/// `affineTransform`
/// `anchorPoint`
///
/// These properties cannot be modified on the layer during the time that
@jwilling
jwilling / NSString+IBNMetrics.h
Created Jan 3, 2014
Better string metrics on OS X.
View NSString+IBNMetrics.h
#import <Foundation/Foundation.h>
@interface NSString (IBNMetrics)
- (CGSize)ibn_sizeConstrainedToSize:(CGSize)size font:(NSFont *)font;
- (CGSize)ibn_sizeWithFont:(NSFont *)font;
@end
View osx-for-hackers.sh
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
You can’t perform that action at this time.