Skip to content

Instantly share code, notes, and snippets.

View svyatoslav-zubrin's full-sized avatar

Slava svyatoslav-zubrin

  • Kharkiv, Ukraine
View GitHub Profile
@svyatoslav-zubrin
svyatoslav-zubrin / record_gif.swift
Last active January 21, 2019 14:18
Record gif from animated view
import ImageIO
import MobileCoreServices
class MyAnimatedViewTToBeRecordedAsGif: UIView {
private var timer: Timer!
private var isRecording = false
private var images = [UIImage]()
private var timeInterval: TimeInterval = 0.05 // 20 frames per sec
@svyatoslav-zubrin
svyatoslav-zubrin / Animation.md
Created May 19, 2017 06:38 — 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
// The MIT License (MIT)
//
// Copyright (c) 2014 Nate Cook
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: