gokulgovind / GLNotificationBar

GLNotificationBar is a ios10 style notification bar, can be used to handle push notification in active state.
MIT License
301 stars 44 forks source link

Notification Bar Message Label multiline. Lengthen its height according to content. #7

Closed Rashesh-Bosamiya closed 7 years ago

Rashesh-Bosamiya commented 7 years ago

The current problem is truncating trailing characters when content is bigger.

label height should grow.

Is there any solution?

gokulgovind commented 7 years ago

Yup,

  1. In setUpNotificationBar add notificationBar.body.numberOfLines = 0
  2. And change Vertical VFL as let vertical = NSLayoutConstraint.constraintsWithVisualFormat("V:|[view(>=barHeight)]", options: [], metrics: ["barHeight":BAR_HEIGHT], views: ["view":notificationBar]) constraints += vertical
gokulgovind commented 7 years ago

If you want notification bar to stop expanding at particular point, Just change number of lines something not equal to 0 notificationBar.body.numberOfLines = 5

Rashesh-Bosamiya commented 7 years ago

Ok, Let me check.

Rashesh-Bosamiya commented 7 years ago

Fine, This solution working.

Thank you very much. Appreciate.

Just wondering, Does it support attributedString ?

gokulgovind commented 7 years ago

Yes it does, but need to change some code.

  1. Change init method as @objc public init(title:String!, message :NSMutableAttributedString!, preferredStyle:GLNotificationStyle, handler: ((Bool) -> Void)?) {
  2. And change setUpNotificationBar method as private func setUpNotificationBar(header:String, body:NSAttributedString, notificationStyle:GLNotificationStyle) {
  3. In setUpNotificationBar method change notificationBar.body.text as notificationBar.body.attributedText
  4. And init notification bar as let notificationBar = GLNotificationBar(title: "", message: 'Pass you NSMutableAttributedString here', preferredStyle: .SimpleBanner, handler: nil) NOTE: title must be empty in this case.
Rashesh-Bosamiya commented 7 years ago

Thank you very much!!! :1st_place_medal: