Skip to content

Instantly share code, notes, and snippets.

View Pasanpr's full-sized avatar

Pasan Premaratne Pasanpr

View GitHub Profile
@Pasanpr
Pasanpr / TextSize.swift
Created May 9, 2017 02:30 — 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)