public static CGRect CGRectStandardize(CGRect rect)
{
bool horiz = (rect.size.width > 0);
bool vert = (rect.size.height > 0);
float w = horiz ? rect.size.width : -rect.size.width;
float h = horiz ? rect.size.height : -rect.size.height;
float x = horiz ? rect.origin.x : rect.origin.x - w;
float y = vert ? rect.origin.y : rect.origin.y - h;
return CGRectMake(x, y, w, h);
}