Skip to content

Instantly share code, notes, and snippets.

View khorbushko's full-sized avatar
💭
🇺🇦

hbk3 khorbushko

💭
🇺🇦
View GitHub Profile
@khorbushko
khorbushko / UIBezierPath + Rotation
Created June 10, 2019 08:42
UIBezierPath + Rotation
extension UIBezierPath {
// MARK: - UIBezierPath + Rotation
func rotatePath(degree: CGFloat) {
let bounds: CGRect = self.cgPath.boundingBox
let center: CGPoint = CGPoint(x: bounds.midX, y: bounds.midY)
let radians: CGFloat = (degree / 180.0 * .pi)
var transform: CGAffineTransform = CGAffineTransform.identity
@khorbushko
khorbushko / UIBezierPath + Icon
Created June 10, 2019 08:42
UIBezierPath + Icon
import UIKit
extension UIBezierPath {
// MARK: - UIBezierPath + Icon
class func checkMark(_ frame: CGRect) -> UIBezierPath {
let origin = frame.origin
let diameter = frame.height
@khorbushko
khorbushko / UIViewController+UIScreenEdgePanGestureRecognizer
Created July 30, 2017 15:05
Extension for UIViewController that allow to add UIScreenEdgePanGestureRecognizer to any ViewController with custom selector
import ObjectiveC
private var handler: Selector?
extension UIViewController {
// MARK: - UIViewController+ScreenEdge
private var swipeGestureSelector:Selector? {
get {
if let obj = objc_getAssociatedObject(self, &handler) as? Selector {
@khorbushko
khorbushko / PHPhotoLibrary+SaveImage
Created December 29, 2016 09:27
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
func save() {
@khorbushko
khorbushko / TimerWithGCD.md
Created May 4, 2016 12:19
Creating a timer with Grand Central Dispatch

##Creating a timer with Grand Central Dispatch

At the following is the implementation file of a sample class that shows, how to make a timer with the help of Grand Central Dispatch. The timer fires on a global queue, just change the queue to the main queue or any custom queue and the timer fires on this queue and not on the global queue anymore.

#import <Foundation/Foundation.h>

@interface SampleClass : NSObject
- (void)startTimer;
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@khorbushko
khorbushko / Animation.md
Created March 25, 2016 22:02 — forked from JeOam/Animation.md
iOS Core Animation: Advanced Techniques, Part 1: The Layer Beneath

1. The Layer Tree

Core Animation's original name is Layer Kit

Core Animation is a compositing engine; its job is to compose different pieces of visual content on the screen, and to do so as fast as possible. The content in question is divided into individual layers stored in a hierarchy known as the layer tree. This tree forms the underpinning for all of UIKit, and for everything that you see on the screen in an iOS application.

In UIView, tasks such as rendering, layout and animation are all managed by a Core Animation class called CALayer. The only major feature of UIView that isn’t handled by CALayer is user interaction.

There are four hierarchies, each performing a different role:

  • view hierarchy
  • layer tree
@khorbushko
khorbushko / OSStatus.m
Created March 3, 2016 12:54 — forked from zoul/OSStatus.m
Decode OSStatus error codes into strings.
NSString *NSStringFromOSStatus(OSStatus errCode)
{
if (errCode == noErr)
return @"noErr";
char message[5] = {0};
*(UInt32*) message = CFSwapInt32HostToBig(errCode);
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding];
}