0
我正在为日历创建UIView子类,其中带有流布局的UICollectionView用于显示日期。该代码是:UICollectionViewFlowLayout minimumLineSpacing不适用于整个集合视图 - Swift
override func draw(_ rect: CGRect)
{
super.draw(rect)
.
.
configureCalendarView()
.
}
func configureCalendarView()
{
cellWd = Double(self.frame.size.width)/7.0
let layout = UICollectionViewFlowLayout.init()
layout.minimumLineSpacing = 0.5
layout.minimumInteritemSpacing = 0.0
layout.sectionInset = UIEdgeInsetsMake(1, 0, 0, 0)
collectionV = UICollectionView.init(frame: CGRect(x: 0, y:90, width:self.frame.size.width, height:CGFloat(cellWd * 5 + 3.5)), collectionViewLayout: layout)
collectionV?.backgroundColor = self.backgroundColor
collectionV?.isScrollEnabled = false
collectionV?.register(DayCell.classForCoder(), forCellWithReuseIdentifier:reuseID)
collectionV?.dataSource = self;
collectionV?.delegate = self;
collectionV?.backgroundColor = calBgColor //lightgray
self.addSubview(collectionV!)
}
一切工作正常,但最小线间距是不是有第二和第三排之间有任何影响。下面是截图:
请告诉我去错了吗?任何帮助将不胜感激。谢谢 !
感谢您的快速答复。但它不工作。 – iAkki
CGFloat(cellWd * 5 + 3.5))你必须修正这里的计算,+ 5.0/screenScale – 2017-01-16 11:57:54
也试着改变它,但它只是增加底部边框,因为collectionview的高度增加了(并且背景颜色是浅灰色) – iAkki