Skip to content

Commit

Permalink
adjust the size of label if text is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
zzjzz9266a committed Jun 2, 2017
1 parent e5e5d87 commit 7c43616
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SwiftNotice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ class SwiftNotice: NSObject {
label.font = UIFont.systemFont(ofSize: 13)
label.textAlignment = NSTextAlignment.center
label.textColor = UIColor.white
label.sizeToFit()
let size = label.sizeThatFits(CGSize(width: UIScreen.main.bounds.width-82, height: CGFloat.greatestFiniteMagnitude))
label.bounds = CGRect(x: 0, y: 0, width: size.width, height: size.height)
mainView.addSubview(label)

let superFrame = CGRect(x: 0, y: 0, width: label.frame.width + 50 , height: label.frame.height + 30)
Expand Down

0 comments on commit 7c43616

Please sign in to comment.