1

How can generate the flexbox layout with button please check the attach image. Any library available? Or can make with collectionView.

enter image description here

1 Answers1

0

Yes you should use a collection view, and implement this delegate function

func collectionView(_ collectionView: UICollectionView,
                    layout collectionViewLayout: UICollectionViewLayout,
                    sizeForItemAt indexPath: IndexPath) -> CGSize {

    var str: String = data[indexPath.row]
    let font: UIFont = /*Your Font*/
    let size: CGSize = str.size(withAttributes: [NSAttributedString.Key.font: font])

    return CGSize(width: size.width + 39, height: 45)
Soufian Hossam
  • 487
  • 5
  • 16