_showImageView.center = self.center;
_showImageView.size = _showImage.size;
NSLog(@"第一种: _showImageView.frame === %@", NSStringFromCGRect(_showImageView.frame));
_showImageView.center = self.center;
_showImageView.bounds = (CGRect){CGPointZero, _showImage.size};
NSLog(@"第二种: _showImageView.frame === %@", NSStringFromCGRect(_showImageView.frame));
2014-09-23 10:41:59.311 NeiHanShe[6205:60b] 第一种: _showImageView.frame === {{160, 284}, {265, 146.13971}}
2014-09-23 10:41:59.311 NeiHanShe[6205:60b] 第二种: _showImageView.frame === {{27.5, 210.93015}, {265, 146.13971}}
所有正确设置,应该选择第二种,否则不会居中, 第一种的self.center 会当做_showImageView.frame 的 x y
iOS 同时设置view的 center 跟 size 的注意细节
原文地址:http://blog.csdn.net/alincexiaohao/article/details/39495237