Skip to content

Instantly share code, notes, and snippets.

@Lancewer
Created January 17, 2018 02:26
Show Gist options
  • Save Lancewer/53f835db38e06fbc42b01bda4bd69a62 to your computer and use it in GitHub Desktop.
Save Lancewer/53f835db38e06fbc42b01bda4bd69a62 to your computer and use it in GitHub Desktop.
[GetStringSize] how to get the string size rect in iOS #String #Swift #iOS #size #UI

#This snippet shows how to get the string size rect in interface Notice the target string must be NSString type not String type in swift

let cellTitle:NSString = "string to calculate"
var autoSize = cellTitle.size(withAttributes: [NSAttributedStringKey.font:UIFont.systemFont(ofSize: 17.0)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment