ios - Making a triangle in a UIView with a CGRect Frame -
hi making game , need spike @ bottom have decided via uiview , collisions. coding in swift.
i have square:
class="lang-swift prettyprint-override"> //object setup allow square = uiview(frame: cgrect(x:100, y:100, width: 100, height: 100)) square.backgroundcolor = uicolor.purplecolor() view.addsubview(square)
and triangle, have image can utilize triangle image square certainly collision when touches image borders not actual trianlge borders please advice on how image or how got square.
thanks
alex
there tutorial here:
http://jamesonquave.com/blog/drawing-custom-views-with-swift-andrew-vanwagoner/
with code this:
func drawplaypathto(context: cgcontextref, boundedby rect: cgrect) { cgcontextsetfillcolorwithcolor(context, uicolor.blackcolor().cgcolor) cgcontextmovetopoint(context, rect.width / 4, rect.height / 4) cgcontextaddlinetopoint(context, rect.width * 3 / 4, rect.height / 2) cgcontextaddlinetopoint(context, rect.width / 4, rect.height * 3 / 4) cgcontextaddlinetopoint(context, rect.width / 4, rect.height / 4) cgcontextfillpath(context) }
ios uiview swift cgrect
No comments:
Post a Comment