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

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -