|
@@ -335,11 +335,16 @@ public func jsonStringToArray(jsonString: String) -> [Any]? {
|
|
|
/// - font: <#font description#>
|
|
|
/// - size: <#size description#>
|
|
|
/// - Returns: <#description#>
|
|
|
-public func sizeWithText(text: String, font: UIFont, size: CGSize) -> CGSize {
|
|
|
- let attributes = [NSAttributedString.Key.font: font]
|
|
|
+public func sizeWithText(attributedText: NSMutableAttributedString? = nil,text: String, font: UIFont, size: CGSize) -> CGSize {
|
|
|
let option = NSStringDrawingOptions.usesLineFragmentOrigin
|
|
|
- let rect: CGRect = text.boundingRect(with: size, options: option, attributes: attributes, context: nil)
|
|
|
- return rect.size
|
|
|
+ if attributedText != nil {
|
|
|
+ let rect: CGRect = attributedText?.boundingRect(with: size, options: option, context: nil) ?? CGRect.init(origin: CGPoint.zero, size: size)
|
|
|
+ return rect.size
|
|
|
+ } else {
|
|
|
+ let attributes = [NSAttributedString.Key.font: font]
|
|
|
+ let rect: CGRect = text.boundingRect(with: size, options: option, attributes: attributes, context: nil)
|
|
|
+ return rect.size
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// 根据行数计算字符串大小
|
|
@@ -696,7 +701,7 @@ public func updateTimeToCurrenTime(timeInterval: TimeInterval) -> String {
|
|
|
let date = NSDate(timeIntervalSince1970: timeInterval)
|
|
|
let dfmatter = DateFormatter()
|
|
|
// yyyy-MM-dd HH:mm:ss
|
|
|
- dfmatter.dateFormat = "yyyy年M月d日"
|
|
|
+ dfmatter.dateFormat = "yyyy年M月d日 HH:mm"
|
|
|
|
|
|
var dfmatterStr = dfmatter.string(from: date as Date)
|
|
|
|