Skip to content

Instantly share code, notes, and snippets.

@urouro-net
Created January 15, 2017 10:12
Show Gist options
  • Save urouro-net/ba338649dcb59d1f32af4555e58c10f3 to your computer and use it in GitHub Desktop.
Save urouro-net/ba338649dcb59d1f32af4555e58c10f3 to your computer and use it in GitHub Desktop.
Swift 3, Caluculate view size
let string: NSString = place as NSString
let attributes: [String: AnyObject] = [NSFontAttributeName: UIFont(name: "HiraKakuProN-W6", size: 10.0)!]
let labelHeight: CGFloat = 14.0
let size: CGSize = string.boundingRect(
with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: labelHeight),
options: .usesLineFragmentOrigin,
attributes: attributes,
context: nil).size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment