【发布时间】:2015-10-18 05:30:35
【问题描述】:
对于具有客户 UICollectionViewCell 和 UICollectionViewLayout 的自定义 UICollectionView 在设备旋转后如何触发重绘(即调用 drawrect)?
自定义 UICollectionViewCell 的额外功能:
override func drawRect(rect: CGRect) {
let path = UIBezierPath(roundedRect: self.bounds.insetBy(dx: 1, dy: 1), cornerRadius: 50)
path.lineWidth = 3
UIColor.blueColor().setStroke()
path.stroke()
}
旋转前
旋转后(布局已更新,注意到标签已移动,但在 drawRect 中绘制的椭圆没有,并且日志显示旋转时未调用“drawRect”)
【问题讨论】:
标签: ios swift uikit uicollectionview uicollectionviewlayout