我的代码:
CGFloat scaleFactor = newSize.width / oldSize.width;
CGFloat newCenterX = center_.x * scaleFactor;
CGFloat newCenterY = center_.y * scaleFactor;
CGPoint newCenter = CGPointMake(newCenterX, newCenterY);
//newCenter.x = newCenterX;
//newCenter.y = newCenterY;
CGFloat newRaduis = raduis_ * scaleFactor;
newCenter.y += newSize.height - ceilf(scaleFactor) * oldSize.height;
NSLog(@"Convertion from %@ to %@", NSStringFromCGSize(oldSize), NSStringFromCGSize(newSize));
NSLog(@"old center = %@, old radius = %f", NSStringFromCGPoint(center_), raduis_);
NSLog(@"new center = %@, new radius = %f", NSStringFromCGPoint(newCenter), newRaduis);
NSLog(@"new center x = %f, new center y = %f", newCenterX, newCenterY);
并输出:
2012-09-14 14:18:35.027 TestApp[425:4b93] Convertion from {1080, 1920} to {320, 415}
2012-09-14 14:18:35.031 TestApp[425:4b93] old center = {246, 822}, old radius = 20.000000
2012-09-14 14:18:35.033 TestApp[425:4b93] new center = {73, -1261}, new radius = 5.925926
2012-09-14 14:18:35.035 TestApp[425:4b93] new center x = 73, new center y = 244
在输出中 - 新中心 = {73, -1261},新半径 = 5.925926。为什么中心y值为负?我做错了什么?
提前感谢您的帮助