使用Button生成FlexBox布局 [英] Generating FlexBox layout with Button
本文介绍了使用Button生成FlexBox布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过按钮生成Flexbox布局,请检查附件图像.有图书馆吗?或者可以使用collectionView制作.
How can generate the flexbox layout with button please check the attach image. Any library available? Or can make with collectionView.
推荐答案
是的,您应该使用集合视图并实现此委托函数
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)
这篇关于使用Button生成FlexBox布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文