1

I am adding Continue reading in the last. If there is any line break in the text, the continue reading is not visible. Is this iOS specific bug or I am missing something?

let activityData.feed = "Hi this is \n \n stack overflow" let formattedString = NSMutableAttributedString() formattedString.normal(activityData.feed!).bold(LanguageManager.shared.getLocale(key: "Continue Reading")) labelFeed.attributedText = formattedString 

Extension of attributed string

extension NSMutableAttributedString { @discardableResult func bold(_ text:String) -> NSMutableAttributedString { let attrs:[String:AnyObject] = [NSFontAttributeName : UIFont.systemFont(ofSize: 16.0), NSForegroundColorAttributeName : UIColor.CNS_BlueColor] let boldString = NSMutableAttributedString(string:"\(text)", attributes:attrs) self.append(boldString) return self } @discardableResult func normal(_ text:String)->NSMutableAttributedString { let normal = NSAttributedString(string: text) self.append(normal) return self } } 

enter image description here

3
  • It seems like you are either not resizing the label to fit its contents or having a label with a fixed two-line height. Commented Dec 4, 2017 at 9:42
  • I'd say that's maybe you allowed only 2 lines on your label, or simply the height of the label/textview is not enough. Commented Dec 4, 2017 at 9:43
  • @the4kman, I verified that label's height is appropriate or not. I have tap gesture on label, on click label is expanding properly. Also I set the truncate to the middle(means continue reading will always shown in the end). Commented Dec 4, 2017 at 9:44

1 Answer 1

9

Did you try the html tag <br> instead of \n ? If you already have an attributedstring, take antvantage of the html tags.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.