iphone - Can I use UIBezierPath to draw a shadow image around a UITableView section? -
i have shadow image draw around outer edge of grouped uitableview section. image:
i can uibezierpath represents rect want draw around, can't figure out how repeat image along route of rect. far fills rect image:
uiimage *patternimg = [uiimage imagenamed:@"cellshadow"]; uicolor *fill = [uicolor colorwithpatternimage:patternimg]; [fill setfill]; cgrect asectrect = [self rectforsection:0]; uibezierpath *asectpath = [self createroundedpath:asectrect]; [asectpath fill];
is possible? need do?
unfortunately, there's no way have uibezierpath use image "brush" you'd want. can have coregraphics draw shadow you:
cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetshadow(context, cgsizezero, myshadowradius); // draw shape here
now if draw 1 shape shadow. if draw more shapes, each own shadow might not want. solution called transparency layer, not related calayers or kind of "grouping" in coregraphics:
cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetshadow(context, cgsizezero, myshadowradius); cgcontextbegintransparencylayer(context, null); // draw shapes here. cgcontextendtransparencylayer(context);
between cgcontextbegintransparencylayer
, cgcontextendtransparencylayer
calls shadow disabled. after cgcontextendtransparencylayer
call, shadow applied has been drawn between begin , end if 1 shape.
Comments
Post a Comment