Skip to content

Instantly share code, notes, and snippets.

View maximbilan's full-sized avatar
🧑‍🚒
Working...

Maksym Bilan maximbilan

🧑‍🚒
Working...
View GitHub Profile
@maximbilan
maximbilan / YouTubeParseLinks.swift
Created October 20, 2015 12:59
YouTubeParseLinks.swift
@maximbilan
maximbilan / YouTubeParseLinks.m
Last active October 20, 2015 13:02
YouTubeParseLinks.m
@maximbilan
maximbilan / EventMonitor.swift
Created October 21, 2015 17:29
Mac OS X Event Monitor
import Cocoa
public class EventMonitor {
private var monitor: AnyObject?
private let mask: NSEventMask
private let handler: NSEvent? -> ()
public init(mask: NSEventMask, handler: NSEvent? -> ()) {
self.mask = mask
@maximbilan
maximbilan / AppDelegate.swift
Created October 21, 2015 17:34
Mac OS X Application Popup App Delegate
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2)
let popover = NSPopover()
var eventMonitor: EventMonitor?
func applicationDidFinishLaunching(aNotification: NSNotification) {
@maximbilan
maximbilan / tvOSCustomButtonHighlighting.swift
Last active October 30, 2015 18:48
tvOS Custom Button Highlighting
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
context.nextFocusedView!.layer.shadowOffset = CGSizeMake(0, 15)
context.nextFocusedView!.layer.shadowOpacity = 0.6
context.nextFocusedView!.layer.shadowRadius = 50
context.nextFocusedView!.layer.shadowColor = UIColor.redColor().CGColor
context.previouslyFocusedView?.layer.shadowOpacity = 0
}
import Foundation
import UIKit
@objc public class LeftAlignedSearchBar: UISearchBar, UISearchBarDelegate {
override public var placeholder:String? {
didSet {
if #available(iOS 9.0, *) {
if let text = placeholder {
if text.characters.last! != " " {
let attr = UITextField.appearanceWhenContainedInInstancesOfClasses([LeftAlignedSearchBar.self]).defaultTextAttributes
import Foundation
public extension UIColor {
class func StringFromUIColor(color: UIColor) -> String {
let components = CGColorGetComponents(color.CGColor)
return "[\(components[0]), \(components[1]), \(components[2]), \(components[3])]"
}
class func UIColorFromString(string: String) -> UIColor {
@maximbilan
maximbilan / SKTextureGradient.swift
Last active January 1, 2016 16:15
SKTextureGradient
//
// SKTextureGradient.swift
// Linear gradient texture
// Based on: https://gist.github.com/Tantas/7fc01803d6b559da48d6, https://gist.github.com/craiggrummitt/ad855e358004b5480960
//
// Created by Maxim on 1/1/16.
// Copyright © 2016 Maxim Bilan. All rights reserved.
//
import SpriteKit
import UIKit
public enum DeviceSpecific {
case iPhone
case iPhoneRetina
case iPhone5
case iPhone6
case iPhone6Plus
case iPad
case iPadRetina
- (void)loadView
{
[super loadView];
...
NSString *nibName = someCondition ? @"OneXIB" : @"AnotherXIB";
UINib *nib = [UINib nibWithNibName:nibName bundle:nil];
[nib instantiateWithOwner:self options:nil];
}