Skip to content

Commit

Permalink
。。
Browse files Browse the repository at this point in the history
  • Loading branch information
AnneBlair committed Apr 6, 2017
1 parent f9780fc commit cda6963
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions YYGRegular/YYGRegular/YYGText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ extension String {
return str1 + content + str2
}

/// 计算字符串宽高
///
/// - Parameter size: size
/// - Returns: CGSize
func getStringSzie(size: CGFloat = 10) -> CGSize {
let baseFont = UIFont.systemFont(ofSize: size)
let size = self.size(attributes: [NSFontAttributeName: baseFont])
let width = ceil(size.width) + 5
let height = ceil(size.height)
return CGSize(width: width, height: height)
}

/// 输入字符串 输出数组
/// e.g "qwert" -> ["q","w","e","r","t"]
/// - Returns: ["q","w","e","r","t"]
Expand Down

0 comments on commit cda6963

Please sign in to comment.