Skip to content

Instantly share code, notes, and snippets.

View zhangqifan's full-sized avatar

Shuhari zhangqifan

View GitHub Profile
@zhangqifan
zhangqifan / AnimatedGlyphLabel.swift
Created August 1, 2026 09:24
AnimatedGlyphLabel — a single-line UIKit label that transitions text one glyph at a time (CoreText layout, per-glyph spring + gaussian blur stagger). Self-contained, iOS 13+, zero dependencies.
#if os(iOS)
import CoreImage
import CoreImage.CIFilterBuiltins
import CoreText
import UIKit
/// A single-line UIKit label that transitions text one glyph at a time.
///
/// The intrinsic content size follows the current text. Glyphs are laid out
/// individually from the leading edge, which suits short strings such as
@zhangqifan
zhangqifan / array-sorting-extension.swift
Last active May 14, 2020 14:39
Sorting custom objects array by another array with a specific property in Swift
/// These implementations of sorting based on a specific property of custom object. For example:
/// struct Person {
/// var age: Int
/// var name: String
/// }
///
/// // Case 1:
/// let people = [Person(age: 10, name: "Tom"), Person(age: 12, name: "John"), Person(age: 20, name: "Peter"), Person(age: 1, name: "Nancy")]
/// let orderedPeople = [Person(age: 12, name: "John"), Person(age: 10, name: "Tom")]
///