UIViewcenter属性是该view相对其父视图的中心位置 假如有blueView和其子视图redView

redView.center = blueView.center;
结果是这样的     想要下面这种,有两种方法
wrong     right
  • 将父视图坐标转换到当前视图
redView.center = [blueView convertPoint:blueView.center fromView:blueView.superview];
  • 使用blueViewbounds计算中心点坐标
redView.center = CGPointMake(CGRectGetMidX(blueView.bounds), CGRectGetMidY(blueView.bounds));