Closed Mackarous closed 9 years ago
@Mackarous Have you given preferred width?
@Mackarous I figured out the issue. I need some more time to fix this. For the time being, you can programmatically set the truncation token.
@hsusmita I have a preferred width, and I attempted to set the truncation token programatically also but it still doesn't work.
@Mackarous Does it show default ellipse?
Yes it does
@Mackarous Is there any error regarding IBDesignable?
No error for IBDesignable at all
@Mackarous, I am unable to diagnose the issue. It should work programmatically. Can you share sample code on github? It would be helpful in understanding the issue.
Sure. I simply add a label to my storyboard. The label has top, bottom, left, and right constraints. No height or width constraints. It has numberOfLines = 5, and I add too much text so it must truncate. I then use the following lines of code:
let token = "... More"
let attributedString = NSMutableAttributedString(string: token, attributes: [NSFontAttributeName : self.label.font])
self.label.setAttributedTruncationToken(attributedString, withAction: { tappedString in
println("hit")
})
self.label.setText(self.labelText, withTruncation: true)
@Mackarous Updated library. Try latest version, i.e 1.0.4 and let me know if there is still any issue. FYI, I will be releasing swift implementation of ResponsiveLabel by the end of this week.
@hsusmita Thank you! It works perfectly now! Great work. Also just wondering if you are planning on putting hit state on the truncation token?
@Mackarous What do you mean by hit state? Is it something like highlighting the token on tap?
@hsusmita yes exactly
@Mackarous The bug in highlighting token is fixed. Check the version 1.0.5. Here is the sample code is
let token = "... Read More"
let attributedString = NSMutableAttributedString(string: token, attributes: [NSFontAttributeName : self.label.font
,RLHighlightedBackgroundColorAttributeName:UIColor.blackColor(),RLHighlightedForegroundColorAttributeName:UIColor.greenColor(),NSForegroundColorAttributeName:UIColor.redColor()])
self.label.setAttributedTruncationToken(attributedString, withAction: { tappedString in
println("hit")
})
self.label.setText(self.labelText, withTruncation: true)
Perfect! Thank you so much!
I am trying to set the truncation token in IB, but I do not have width/height constraints. I have top, bottom, left, right constraints instead. The UILabel is set to be a ResponsiveLabel, number of lines = 0.
The token shows in IB, but not when the app runs
Any ideas?