Skip to content

Instantly share code, notes, and snippets.

View conscientiousness's full-sized avatar
🧑‍💻
Coding Mode

Jesse Lin conscientiousness

🧑‍💻
Coding Mode
View GitHub Profile
@conscientiousness
conscientiousness / TextSize.swift
Created April 25, 2019 07:02 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)