ios - How to draw a line in the simplest way in swift -


i new swift , xcode , trying make tic tac toe game. have figured out except how draw line through 3 x's or o's. have no idea on how draw lines. have looked on web answer , can't figure out. can help.

thanks ahead

try looking uibezierpath lot drawing lines. documentation here example:

override func drawrect(rect: cgrect) {       var apath = uibezierpath()        apath.movetopoint(cgpoint(x:/*put starting location*/, y:/*put starting location*/))        apath.addlinetopoint(cgpoint(x:/*put next location*/, y:/*put next location*/))        //keep using method addlinetopoint until 1 close path        apath.closepath()        //if want stroke red color       uicolor.redcolor().set()       apath.stroke()       //if want fill        apath.fill() } 

make sure put code in drawrect. in example above.

if need update drawing call setneedsdisplay() update.


Comments

Popular posts from this blog

javascript - How to diff two immutable objects -

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

javascript - React.js: onClick function from child to parent -