
func labelHeight(wIDth:CGfloat,Font:UIFont,text:String)->CGfloat{ let label:UILabel = UILabel.init(frame: CGRect.init(x: 0,y: 0,wIDth: wIDth,height: CGfloat.greatestFiniteMagnitude)) label.numberOflines = 0 label.lineBreakMode = NSlineBreakMode.byWorDWrapPing label.Font = Font label.text = text label.sizetoFit() return height:label.frame.height} 然后将此UICollectionVIEwDelegateFlowLayout方法添加到控制器中并返回标头的大小
func collectionVIEw(_ collectionVIEw: UICollectionVIEw,layout collectionVIEwLayout: UICollectionVIEwLayout,referenceSizeforheaderInSection section: Int) -> CGSize{ // Pass parameter into this function according to your requirement let height = labelHeight(wIDth: collectionVIEw.bounds.wIDth,text:"") return CGSize(wIDth:collectionVIEw.bounds.wIDth,height: height + 10)} 总结 以上是内存溢出为你收集整理的ios – CollectionViewLayout补充视图高度等于内容全部内容,希望文章能够帮你解决ios – CollectionViewLayout补充视图高度等于内容所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)