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

网站的建设需要数据库民政 门户网站 建设

网站的建设需要数据库,民政 门户网站 建设,外贸网站设计模板,湖南营销型网站建设多少钱首先看效果图 实现的思路,支持配置代理,通过代理方式设置 每个item的frame,支持设置头部的size, 支持多个分区,之前做过类似的,但是只支持一个分区, 后来遇到过几次多分区的,都是将一个collec…

首先看效果图
在这里插入图片描述

实现的思路,支持配置代理,通过代理方式设置
每个item的frame,支持设置头部的size,
支持多个分区,之前做过类似的,但是只支持一个分区,
后来遇到过几次多分区的,都是将一个collectionView放到tableViewCell 中实现的,这次为了使layout更强大,支持了多
个分区的,思路就是我们在prepare layout 获取到
分区数量和每个分区cell数量
,然后创建对应的布局属性,添加到一个总的数组中
然后在系统方法中返回整个数组即可

//
//  LBMutilMutilAutoWidthLayout.m
//  TEXT
//
//  Created by mac on 2025/3/30.
//#import "LBMutilMutilAutoWidthLayout.h"@interface LBMutilMutilAutoWidthLayout ()@property (nonatomic, strong) NSMutableArray<UICollectionViewLayoutAttributes *> *layoutAttributesArray;@property (nonatomic, assign) CGSize contentSize;@end@implementation LBMutilMutilAutoWidthLayout- (instancetype)init {if (self = [super init]) {self.layoutAttributesArray = [NSMutableArray new];}return self;
}- (void)prepareLayout {[super prepareLayout];[self updateLayout];
}- (CGSize)collectionViewContentSize {return self.contentSize;
}- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {return self.layoutAttributesArray;
}#pragma mark - ---------- update ----------- (void)updateLayout {// 移除旧的布局[self.layoutAttributesArray removeAllObjects];CGFloat currentY = 0;CGFloat x = self.sectionInset.left;// 计算新的布局NSInteger sectionCount = [self.collectionView numberOfSections];for (int i = 0; i < sectionCount; i ++) {CGSize headerSize = CGSizeZero;if (self.delegate && [self.delegate respondsToSelector:@selector(sizeForHeaderViewAtSection:)]) {headerSize = [self.delegate sizeForHeaderViewAtSection:i];}if (!CGSizeEqualToSize(headerSize, CGSizeZero)) {UICollectionViewLayoutAttributes *layoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathForItem:0 inSection:i]];;layoutAttributes.frame = CGRectMake(0, currentY, headerSize.width, headerSize.height);currentY += headerSize.height;[self.layoutAttributesArray addObject:layoutAttributes];}NSInteger count = 0;if ([self.collectionView.dataSource respondsToSelector:@selector(collectionView:numberOfItemsInSection:)]) {count = [self.collectionView.dataSource collectionView:self.collectionView numberOfItemsInSection:0];}CGFloat currentX = x;if (count > 0) {for (int j = 0; j < count; j++) {CGSize cellSize = [self sizeForItemAtIndexPath:[NSIndexPath indexPathForItem:j inSection:i]];CGFloat cellWidth = cellSize.width;CGFloat cellHeight = cellSize.height;// 创建布局属性UICollectionViewLayoutAttributes *layoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:[NSIndexPath indexPathForItem:j inSection:i]];layoutAttributes.frame = CGRectMake(currentX, currentY, cellWidth, cellHeight);[self.layoutAttributesArray addObject:layoutAttributes];currentX += (self.minimumInteritemSpacing + cellWidth);// 计算下一个item的x,以及布局更新结束检测if (j != count - 1) {if (currentX + cellWidth + self.minimumInteritemSpacing + self.sectionInset.right > self.contentWidth) {currentX = self.sectionInset.left;currentY += self.minimumLineSpacing + cellHeight;}} else {currentY += cellHeight;}if (i == sectionCount - 1 && j == count - 1) {self.contentSize = CGSizeMake(self.contentWidth, currentY);}}}}
}- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)index {CGSize size = CGSizeZero;if ([self.delegate respondsToSelector:@selector(sizeForItemAtIndexPath:)]) {size = [self.delegate sizeForItemAtIndexPath:index];}return size;
}@end

用法

//
//  LBMutilSecionAutoLayoutViewController.m
//  TEXT
//
//  Created by mac on 2025/3/30.
//#import "LBMutilSecionAutoLayoutViewController.h"
#import "LBMutilMutilAutoWidthLayout.h"@interface LBMutilSecionAutoLayoutViewController () <LBMutilMutilAutoWidthLayouttDelegate,
UICollectionViewDelegate,
UICollectionViewDataSource>@property (nonatomic, strong) UICollectionView *collectionView;@end@implementation LBMutilSecionAutoLayoutViewController- (void)viewDidLoad {[super viewDidLoad];[self.view addSubview:self.collectionView];// Do any additional setup after loading the view.
}#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"22" forIndexPath:indexPath];cell.contentView.backgroundColor = [UIColor cyanColor];return cell;
}- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{UICollectionReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];return header;
}- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{return 3;
}- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{return 10;
}
#pragma mark - LBMutilMutilAutoWidthLayouttDelegate- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{CGFloat width;if (indexPath.section == 0) {width = 100;if (indexPath.item %2 == 0) {width = 50;}} else {width = 70;if (indexPath.item %2 == 0) {width = 30;}}return CGSizeMake(width, 20);
}- (CGSize)sizeForHeaderViewAtSection:(NSInteger)section
{return CGSizeMake(375, 40);
}#pragma mark  - lazy load- (UICollectionView *)collectionView
{if (!_collectionView) {LBMutilMutilAutoWidthLayout *layout = [[LBMutilMutilAutoWidthLayout alloc] init];layout.delegate = self;layout.contentWidth = 375;layout.minimumInteritemSpacing = 10;layout.sectionInset = UIEdgeInsetsZero;_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 100, 375, 400) collectionViewLayout:layout];_collectionView.dataSource = self;_collectionView.delegate = self;[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"22"];[_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];}return _collectionView;
}@end

文章转载自:

http://bEFqcwIM.httty.cn
http://iV9THM6L.httty.cn
http://U7To9Bma.httty.cn
http://uyQH4y8O.httty.cn
http://mpB2DsMh.httty.cn
http://JJAUDKcf.httty.cn
http://nHTiLZNB.httty.cn
http://7Y0LWsLb.httty.cn
http://cQyrsZ1u.httty.cn
http://ocHMu4d4.httty.cn
http://vQ3cssWi.httty.cn
http://taVs9vXi.httty.cn
http://HOkfLTu6.httty.cn
http://LM5F3Je9.httty.cn
http://2hQvQJ6a.httty.cn
http://8op2QIy8.httty.cn
http://FVvHzJ0B.httty.cn
http://c80SzlDu.httty.cn
http://ZCUu8v1y.httty.cn
http://qdYoDrue.httty.cn
http://snFeuIKq.httty.cn
http://0V9CrHrr.httty.cn
http://JbCFO65i.httty.cn
http://9ArwLbdk.httty.cn
http://WyBiO5J3.httty.cn
http://Ud7Wn3dr.httty.cn
http://XuoYh6uD.httty.cn
http://3ejLP6Jd.httty.cn
http://iomzBEKX.httty.cn
http://b36Oar0a.httty.cn
http://www.dtcms.com/wzjs/646598.html

相关文章:

  • 苏州高级网站建设网络营销推广的目标
  • 精选赣州网站建设百度竞价排名广告定价鲜花
  • 做网站切片私人推流服务器
  • 织梦网站流动广告代码seowhy是什么意思中文
  • 常用网站名称大全怎样建网站才赚钱
  • 青岛制作网站的网站微信二维码悬浮
  • 建设官方网站的费用账务处理电商网站设计图片
  • 如何自主建设企业网站网站建设大小
  • 深圳推广网站redis 缓存 wordpress
  • PK10如何自己做网站布吉商城网站建设哪家便宜
  • 个人介绍网站模板含关键词的网站建设
  • wordpress建站教程主题做高端品牌网站
  • 做网站如何引用头部西安市建设工程信息网官网
  • seo网站代码优化网站建好了 怎么建后台
  • 芜湖南陵网站建设软件外包网
  • 深圳网站制作公司嘉兴十大互联网营销公司
  • 做医疗健康类网站需要资质吗301网站跳转设置
  • 免费完整版的网站模板wordpress主题 建站
  • 宁夏一站式网站建设磁力链搜索引擎入口
  • 做网站需要买空间么 服务器多语种网站开发
  • 个人相册网站模板公司企业宣传片拍摄
  • 中国建设造价信息网站wordpress如何在首页不显示某类分类目录下的文章?
  • 网站开发编辑器广西网站推广优化
  • 找网站设计公司 看那些手机微信网站建设
  • 保定自助建站国外域名需要备案吗
  • 什么企业网站能自己做最新wordpress漏洞
  • 有那些做自媒体短视频的网站手机做ppt的免费模板下载网站
  • 黄金网站软件app下载安装上海市中学生典型事例网站
  • 中英文网站 程序南昌网站公司
  • 网站建设价格表站长之家特效网站