结果guideImageView.frame和videoPlayerVC.videoPlayerView.的frame竟然不一样。这么一句赋值,竟然等号左边的不一样。颠倒了90°。查了资料后发现原来是view2有个transform啊。
如果在程序中改变了某个控件的transform,那么请不要使用frame计算子控件的布局,应该使用bounds+center代替,官方文档上关于transform属性的说明:
Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.
解决方法比较简单粗暴:
frame.size.height = MIN(videoPlayerVC.videoPlayerView.height, videoPlayerVC.videoPlayerView.width);
frame.size.width = MAX(videoPlayerVC.videoPlayerView.height, videoPlayerVC.videoPlayerView.width);
参考: http://www.jianshu.com/p/9dfd337e8266