当前位置: 首页 > news >正文

济宁祥云网站建设wordpress 分页

济宁祥云网站建设,wordpress 分页,旅游网站前台模板,怎样开网站文章目录 1.瀑布流1.1 demo地址1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和文字的高度 1.瀑布流 1.1 demo地址 CollectionViewWaterfallLayout - github 1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和… 文章目录 1.瀑布流1.1 demo地址1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和文字的高度 1.瀑布流 1.1 demo地址 CollectionViewWaterfallLayout - github 1.2 记得把部署的最低版本由8改成11,13甚至更高。不然编译会报错 2.动态计算图片和文字的高度 //可以正常使用 import UIKit import SnapKit class ConcernedVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {let cellReuseIdentifier WaterfallCelllet itemsPerRow: CGFloat 2let sectionInsets UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)let itemSpacing: CGFloat 10 // Spacing between items in the same columnvar columnHeights: [CGFloat] [0, 0] // Heights of the two columnslet sampleData: [(image: UIImage, text: String)] [(UIImage(named: img_about us_app)!, Sample Text 1),(UIImage(named: banner)!, Sample Text 2adfahdfkajdfiahdofhadoifhaodhfaoihdfhasdifhaidhfapfdhiashf),(UIImage(named: img_about us_app)!, Sample Text 1),(UIImage(named: banner)!, Sample Text 2adfahdfkajdfiahdofhadoifhaodhfaoihdfhasdifhaidhfapfdhiashf),(UIImage(named: img_about us_app)!, Sample Text 1),(UIImage(named: banner)!, Sample Text 2adfahdfkajdfiahdofhadoifhaodhfaoihdfhasdifhaidhfapfdhiashf),(UIImage(named: img_about us_app)!, Sample Text 1),(UIImage(named: img_about us_app)!, Sample Text 1),// Add more sample data here]override func viewDidLoad() {super.viewDidLoad()// let layout UICollectionViewFlowLayout() // Create a layout instance // collectionView UICollectionView(frame: .zero, collectionViewLayout: layout) // Initialize UICollectionView with the layoutcollectionView.delegate selfcollectionView.dataSource selfcollectionView.register(WaterfallCell.self, forCellWithReuseIdentifier: cellReuseIdentifier)collectionView.backgroundColor .white}// MARK: UICollectionViewDataSourceoverride func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) - Int {return sampleData.count}override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) - UICollectionViewCell {let cell collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseIdentifier, for: indexPath) as! WaterfallCelllet data sampleData[indexPath.item]cell.configure(with: data)return cell}// MARK: UICollectionViewDelegateFlowLayoutfunc collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) - CGSize {let paddingSpace sectionInsets.left * (itemsPerRow 1)let availableWidth collectionView.frame.width - paddingSpacelet widthPerItem availableWidth / itemsPerRowlet data sampleData[indexPath.item]let imageAspectRatio data.image.size.width / data.image.size.heightlet textHeight data.text.height(withConstrainedWidth: widthPerItem - 16, font: UIFont.systemFont(ofSize: 14))let imageHeight min(200, widthPerItem / imageAspectRatio) // Limit image heightlet totalHeight imageHeight textHeight 16return CGSize(width: widthPerItem, height: totalHeight)}func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) - UIEdgeInsets {return sectionInsets}func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) - CGFloat {return sectionInsets.left}func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) - CGFloat {return sectionInsets.left} } class WaterfallCell: UICollectionViewCell {let imageView UIImageView()let label UILabel()override init(frame: CGRect) {super.init(frame: frame)contentView.backgroundColor .yellowcontentView.addSubview(imageView)imageView.contentMode .scaleAspectFillimageView.clipsToBounds truecontentView.addSubview(label)label.numberOfLines 2label.font UIFont.systemFont(ofSize: 14)}required init?(coder: NSCoder) {fatalError(init(coder:) has not been implemented)}func configure(with data: (image: UIImage, text: String)) {imageView.image data.imagelabel.text data.textlet imageAspectRatio data.image.size.width / data.image.size.heightlet imageHeight frame.width / imageAspectRatioimageView.frame CGRect(x: 0, y: 0, width: frame.width, height: imageHeight)label.frame CGRect(x: 0, y: imageHeight 8, width: frame.width, height: labelHeight)}private var labelHeight: CGFloat {let labelWidth frame.width - 16return label.text?.height(withConstrainedWidth: labelWidth, font: UIFont.systemFont(ofSize: 14)) ?? 0} } extension String {func height(withConstrainedWidth width: CGFloat, font: UIFont) - CGFloat {let constraintRect CGSize(width: width, height: .greatestFiniteMagnitude)let boundingBox self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil)return ceil(boundingBox.height)} }//使用 let layout UICollectionViewFlowLayout() layout.scrollDirection .vertical let vc ConcernedVC(collectionViewLayout: layout)
http://www.pierceye.com/news/683606/

相关文章:

  • 网站个别页面做seo建立有效的什么机制
  • 学校网站建设模板wordpress 年月归档
  • 凡科做的网站行不行京东慧采入驻条件及费用2023年
  • 汽车网站建设页面网站建设营销公司
  • 可以写代码的网站有哪些问题微信公众号的推广
  • 网站建设项目怎么写新网站一般多久收录
  • 什么网站可以免费发广告合肥做网站一般多少钱
  • 企业网站优化的方式大安市网站
  • 镇江专业网站建设制作wordpress调查插件
  • 桂林网站制作多少钱最好的网站开发公司
  • 广州网站开发公司排名广州从化建设网站官网
  • 网站备案在杭州注册公司需要什么条件
  • 购买域名做销售网站可以吗河北邢台刚刚发布的紧急通知
  • 安溪建设局网站政务网站建设信息
  • 如何做公司自己的网站首页网站建设的钱计入什么科目
  • 网站建设公司行业免费下载网站模版
  • 海外做淘宝网站网站有关于我们的好处
  • 给别人做网站挣钱吗怎么建设推广网站
  • 南宁市网站开发深圳制作app
  • 临海大经建设集团网站雄安做网站
  • 网站设计多少钱通桥小学的网站建设
  • 上海制作网站的公司做彩票网站违法吗
  • ps软件手机版下载百度seo工具
  • 新乡网站关键词优化建设局网站信息管理制度
  • 海南论坛网站建设网站建设怎么放到云空间
  • 中山 灯饰 骏域网站建设专家网站建设需求范文
  • 东光网站建设淘宝店铺装修苏州网站建设服务
  • 平台型网站建设预算表哈尔滨网站制作多少钱
  • 手机网站焦点图装修房子的流程和顺序
  • 做网站一个月赚多少和一起做网店类似的网站