Here i am attempting to draw gridLines for a grid whose border I have successfully created as a SKShapeNode however I am unable to get the lines to be visible when running this code.
func drawGridLines() {
print("drawing")
for row in 0...40 {
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, grid.frame.origin
.x , grid.frame.origin.y + CGFloat(row * 10))
CGPathAddLineToPoint(path, nil, grid.frame.width, grid.frame.origin.y + CGFloat(row * 10))
let shape = SKShapeNode(path: path)
shape.path = path
shape.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
shape.fillColor = UIColor.redColor()
shape.strokeColor = UIColor.blueColor()
shape.lineWidth = 10
addChild(shape)
for col in 0...90 {
print("y")
}
}
}
I copied your code to my project and run, I clearly see those blue grids lines. However, I don't have the variable grid
so I change that to self
which is SKScene
. So I think you have some problem with this grid
, maybe it's out of the screen. Put more codes about the it or change that by yourself, have some tests.