Sometimes my texts are not fitting into their space on UITableViewCell
. They are shrunk with three dots ...
. Is it possible to animate them like Phone App on Android? Like sliding automatically.
Asked
Active
Viewed 84 times
1

do it better
- 4,627
- 6
- 25
- 41
1 Answers
0
Use this class, it's fair easy and you can use just as a drop-in replacement for UILabel:
https://github.com/cbpowell/MarqueeLabel-Swift
To convert UILabel to MarqueeLabel, if you using Storyboard, simply set the class of UILabel object to MarqueeLabel
then setup parameters in viewDidLoad function
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
titleLabel.type = .Continuous
titleLabel.scrollDuration = 15.0
titleLabel.animationCurve = .EaseInOut
titleLabel.fadeLength = 20.0
titleLabel.leadingBuffer = 30.0
titleLabel.trailingBuffer = 20.0
}

Mousavian
- 1,435
- 1
- 15
- 23
-
1please add the code here and give a short explanation on how this solves OP's question. Thanks! – Frakcool Oct 06 '15 at 01:28
-
How can I convert UILabel to MarqueeLabel? – do it better Oct 06 '15 at 14:01
-
I edited to use this with storyboard(xib), if you want init from code tell me. – Mousavian Oct 06 '15 at 14:08
-
I think I should initialize from code because I'm using prototype cells. – do it better Oct 06 '15 at 14:14
-
you can edit cells in storyboard. If you want initialise from code simply add this before this code: textLabel = MarqueeLabel() and setup constrains. the variable must be defined in class, not func, to avoid memory access error – Mousavian Oct 06 '15 at 14:17
-
but textLabel is a get-only property? – do it better Oct 06 '15 at 14:22
-
did you downloaded file from github and added it to your project? – Mousavian Oct 06 '15 at 14:23
-
adding this view to a view controller is like any other view, something like this: http://stackoverflow.com/questions/29030426/how-to-create-custom-view-programmatically-in-swift-having-controls-text-field – Mousavian Oct 06 '15 at 14:27