Skip to content

Instantly share code, notes, and snippets.

View kingnight's full-sized avatar
🎯
Focusing

jinkai kingnight

🎯
Focusing
View GitHub Profile
@kingnight
kingnight / gist:ea323d77e9ad18dde19d5aa3493de1b2
Created December 11, 2018 10:11 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
- (void)addSpriteImage:(UIImage *)image
withContentRect:(CGRect)rect
toLayer:(CALayer *)layer
{
//set image
layer.contents = (__bridge id)image.CGImage;
//scale contents to fit
layer.contentsGravity = kCAGravityResizeAspect;
@kingnight
kingnight / 0_reuse_code.js
Created June 14, 2014 01:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console