Ios 如何使用swift 3在视图中显示栅格
我在视图中得到了网格,但是线条超出了我附加的图像的框架,我得到了一个输出,如何解决这个问题Ios 如何使用swift 3在视图中显示栅格,ios,swift,gridview,Ios,Swift,Gridview,我在视图中得到了网格,但是线条超出了我附加的图像的框架,我得到了一个输出,如何解决这个问题 path = UIBezierPath() path.lineWidth = 5.0 for index in 1...Int(gridWidthMultiple) - 1 { let start = CGPoint(x: CGFloat(index) * gridWidth, y: 0) let end = CGPoint(x: CGFl
path = UIBezierPath()
path.lineWidth = 5.0
for index in 1...Int(gridWidthMultiple) - 1
{
let start = CGPoint(x: CGFloat(index) * gridWidth, y: 0)
let end = CGPoint(x: CGFloat(index) * gridWidth, y: bounds.height)
path.move(to: start)
path.addLine(to: end)
}
let numberOfRows: Int = Int(self.frame.size.height)/Int(gridWidth);
for index in 1...numberOfRows {
let start = CGPoint(x: 0.0, y: gridWidth * CGFloat(index))
let end = CGPoint(x: self.frame.size.width, y: start.y)
path.move(to: start)
path.addLine(to: end)
}
self.setNeedsDisplay()
是否已尝试将栅格视图的clipsToBounds属性设置为true?视图层次结构是什么样的?