Created
January 15, 2019 03:14
-
-
Save dsxsxsxs/daee1312f236ddc7fc6a6f3ced6fce27 to your computer and use it in GitHub Desktop.
swift 4 size of string
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
extension String { | |
var size: CGSize { | |
return size() | |
} | |
public func size(usingFont font: UIFont?) -> CGSize { | |
let f = font ?? UIFont.systemFont(ofSize: 16) | |
let attributes = [NSAttributedStringKey.font: f] | |
return self.size(withAttributes: attributes) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment