iphone - How to draw a triangle programmatically -
i have triangle solver, want way use values answer draw triangle screen matches it.
if subclass uiview can implement in drawrect draw triangle:
-(void)drawrect:(cgrect)rect { cgcontextref ctx = uigraphicsgetcurrentcontext(); cgcontextbeginpath(ctx); cgcontextmovetopoint (ctx, cgrectgetminx(rect), cgrectgetminy(rect)); // top left cgcontextaddlinetopoint(ctx, cgrectgetmaxx(rect), cgrectgetmidy(rect)); // mid right cgcontextaddlinetopoint(ctx, cgrectgetminx(rect), cgrectgetmaxy(rect)); // bottom left cgcontextclosepath(ctx); cgcontextsetrgbfillcolor(ctx, 1, 1, 0, 1); cgcontextfillpath(ctx); }
Comments
Post a Comment