I have cell and in that cell view with textview in it. On textview is border bottom with EZSwiftExtensions
.
Now problem is that border is not full width on first load, but when i scroll down and scroll to top that border is full width.
Why is that happening?
When app loads:
When scroll down and come back to top:
Cell xcode:
Cell code:
import UIKit
import EZSwiftExtensions
class JokeTableViewCell: UITableViewCell {
var item: Joke! {
didSet {
cellView.setCornerRadius(radius: 4)
hearthImg.image = UIImage(named: "HearthWhite")
starImg.image = UIImage(named: "StarWhite")
txtLabel.addBorderBottom(size: 1, color: UIColor.lightGrayColor())
setupCell()
}
}
@IBOutlet weak var cellView: UIView!
@IBOutlet weak var authorLabel: UILabel!
@IBOutlet weak var txtLabel: UILabel!
@IBOutlet weak var hearthImg: UIImageView!
@IBOutlet weak var likesLabel: UILabel!
@IBOutlet weak var starImg: UIImageView!
@IBOutlet weak var scoreLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
func setupCell() {
authorLabel.text = item.creator
if item.creator == "" {
authorLabel.text = "Aninomno"
}
txtLabel.text = item.text
if item.liked == true {
hearthImg.image = UIImage(named: "HearthRed")
}
if item.rated == true {
starImg.image = UIImage(named: "StarYellow")
}
likesLabel.text = item.likes.toString
scoreLabel.text = item.score.toString
}
}
I need it to be full width always.
The implementation of the addBorderBottom
is not that great. You could override layoutSubviews
and use addBorderBottom
there and it should work. However that method is called multiple times and you will end up having multiple borders stacked one over the other. You could implement yourself a border, by using a UIView
with height 1px as subview and some margin contraints, I think this is the easiest solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.