Created
January 15, 2017 10:12
-
-
Save urouro-net/ba338649dcb59d1f32af4555e58c10f3 to your computer and use it in GitHub Desktop.
Swift 3, Caluculate view size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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