ios - Create a semi circle with Core Graphics -
i want create perfect semi circle @ bottom of view , i'm getting arc in top of rectangle (see attached picture). code i'm using following circularrect origin = (x = 128, y = 514), size = (width = 64, height = 54)
cgfloat archeight = 60.0; cgrect arcrect = cgrectmake(circularrect.origin.x, circularrect.origin.y + circularrect.size.height - archeight, circularrect.size.width, archeight); cgfloat arcradius = 60; cgpoint arccenter = cgpointmake(arcrect.origin.x + arcrect.size.width/2, arcrect.origin.y + arcradius); cgfloat angle = acos(arcrect.size.width / (2*arcradius)); cgfloat startangle = 270 * m_pi/180 + angle; cgfloat endangle = 90 * m_pi/180 - angle; cgcontextaddarc(context, arccenter.x, arccenter.y, archeight, startangle, endangle, 1); cgcontextclip(context); cgcontextclearrect(context, arcrect); cgcontextsetfillcolorwithcolor(context, [uicolor greencolor].cgcolor); cgcontextfillrect( context, arcrect); 
what i'm doing wrong? thanks!
the radius you're supplying arc function large. rectangle width being 64, can fit circle has radius of 32 or less in it.
Comments
Post a Comment