Skip to content

Instantly share code, notes, and snippets.

View Eddiegooo's full-sized avatar

Eddie_Fan Eddiegooo

  • Shenzhen City ,Guangdong province ,China
View GitHub Profile
@Eddiegooo
Eddiegooo / UICollectionView 里cell 并排均分布局,不能占满屏幕的bug修复
Last active July 17, 2021 12:41
UICollectionView 里cell 均分,不能占满屏幕的bug修改
- (CGFloat)collectionViewCellWidth:(UICollectionView *)collectionView itemCountPerRow:(NSInteger)count indexPath:(NSIndexPath *)indexPath {
// 处理collectionView小数点bug,因为collectView是智能布局,当出现小数点时会随机分配宽度
NSInteger columnCount = count;
NSInteger cellWidth = round(collectionView.width / columnCount); // 四舍五入
if (indexPath.row % columnCount == 0 ) {
if (cellWidth * columnCount > collectionView.width) {
return cellWidth - (cellWidth * columnCount - collectionView.width);
} else {
return collectionView.width - cellWidth * (columnCount - 1);
@Eddiegooo
Eddiegooo / SwiftExtension
Created August 18, 2022 09:42
Swift面向协议编程 —— 给系统、自定义的类 添加扩展能力
//
// ExtensionFile.swift
// TestSwift
//
// Created by Eddie on 2022/8/18.
//
import UIKit
import SwiftUI