<span style="font-size:18px;"> // MARK:返回字符串的宽度 func returnWidth(string:NSString) -> CGFloat { let size: CGSize = string.sizeWithAttributes([NSFontAttributeName: UIFont.systemFontOfSize(16.0)]) return size.width } </span>
原文:http://blog.csdn.net/liulicsdn/article/details/43308205