Home > Net >  How to make a line break in a label in Xib
How to make a line break in a label in Xib

Time:01-26

I am trying to make a line break to my icon description, and I tried with /n and checking the multiple lines option in the interface builder.

enter image description here

Aqui es donde saco los datos de mi Icon

enter image description here

It should be noted that my icon is a CollectionViewCell that is generated inside a tableViewCell:

extension MiniAppsShorcuts : UICollectionViewDelegate, UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return self.listAr.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AccesosRapidos", for: indexPath) as? AccesosRapidos else {return UICollectionViewCell()}
            cell.labelAR.text = listAr[indexPath.row].name
        cell.fetchImage(urlString: listAr[indexPath.row].urlImage)
            return cell
    }
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)  {
        delegate?.alert()
    }
    
}

enter image description here

CodePudding user response:

Make sure to set your cell.labelAR numberOfLines to zero and lineBreakMode to byWordWrapping. The default value is byTruncatingTail. That’s why it is truncating your label. Make sure your label and your cell heights are large enough to have multiple lines.

  •  Tags:  
  • Related