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

枣阳网站建设吧seo入门课程

枣阳网站建设吧,seo入门课程,企业网站设计制作教程,郴州刚刚发生的事文章目录 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.yutouwan.com/news/470754/

相关文章:

  • 江都区城乡建设局网站做网站网页
  • 网站建设首先要企业网站建设合同方案
  • 网站注销申请表江苏建设类专业技术人员资格考试
  • 微信公众号网站建设网站建设公司清明雨上
  • 鞍山网站开发军事时事新闻最新消息
  • 凡科建站后台登录社团建设制作网站费用会计科目
  • 有没有可以做app的网站宁波网站建设应届生
  • 邢台专业做移动网站wordpress缩略图字段
  • 做网站要固定电话建设网站与维护
  • 长春专业网站建设推广网天下网站建设
  • 中国建设工程标准化协会网站沈阳男科医院好吗
  • 海伦市网站拍企业宣传片多少费用
  • .net网站费用asp网站会员注册不了
  • 公司网站用个人备案 2018wordpress安装 windows
  • 网站开发的图片要求免费的外贸发布平台
  • 厦门知名做企业网站设计的公司中山中小企业网站建设
  • 邢台专业网站建设价格学校网站建设策划
  • 做推广必须知道的网站吗上海企业服务
  • 在线网站代码生成器哪个网站可以做字体
  • 奉节网站建设公司和萝莉做的电影网站
  • 高端网站开发制作青浦手机网站制作
  • 济南历山北路网站建设软件定制开发招标
  • 高端网站制作公网站设计培训成都
  • 网站公司市场营销方案wordpress图片并排
  • 苏州工程建设网抖音推广seo
  • 国内产品设计网站单片机项目外包网站
  • 做实验学编程的网站中国建设银行安徽分行网站
  • 沈阳有什么网站下载微信公众号平台官网
  • 网站图片广告代码网站推广方案怎么写
  • 网站建设diy二十条优化