You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//
import UIKit
class AllRecipientTableViewCell: UITableViewCell { @IBOutlet weak var logoLabel: UILabel! { didSet { self.logoLabel.clipsToBounds = true self.logoLabel.layer.cornerRadius = self.logoLabel.frame.width/2 } } @IBOutlet weak var usernameLabel: UILabel!
var nameInitials: String? { guard let name = self.usernameLabel.text?.components(separatedBy: " "), name.count > 1 else { let _name = self.usernameLabel if (_name?.text?.count ?? 0) >= 2 { let first2 = String(_name?.text?.prefix(2) ?? "") return first2.uppercased() } else { return (_name?.text ?? "").uppercased() } } let first1 = String(name[0].prefix(1)) let second1 = String(name[1].prefix(1)) return first1.uppercased() + second1.uppercased() } override func awakeFromNib() { super.awakeFromNib() // Initialization code }
override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated)
// Configure the view for the selected state } func setUp(model: Recipient?) { self.usernameLabel.text = model?.fullName ?? "" self.logoLabel.text = nameInitials }
}
|