Reputation: 2187
I've put a UILabel in my notification content extension storyboard and set it up using auto layout. I've also set the numberOfLines to 0. In the storyboard, it looks perfectly fine but when I use it on my device, the label is coming out to be a single line. Am I missing anything?
Edit (ScreenShots added):
Also, when a new notification comes, I see a blank info and it's updated after a few secs.
More ScreenShots Added:
Number of lines is set to 0.
and in the code I'm setting it like this:
titleString.text = "Saturday SuperBowl Saturday SuperBowl Saturday SuperBowl"
But still it is coming as a single line.
Upvotes: 1
Views: 393
Reputation: 11
You must set the uilabels preferredMaxLayoutWidth. You can do this in your view controller:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
titleString.preferredMaxLayoutWidth = titleString.frame.size.width
self.view.layoutIfNeeded()
}
or subclassing your uilabel:
override func layoutSubviews() {
self.preferredMaxLayoutWidth = self.frame.size.width
super.layoutSubviews
}
Upvotes: 1