我有一个带有一堆图像的 UIScrollView。到目前为止,我已经设法在布局更改时更改滚动视图及其 UIImageViews 的大小。但问题是,当布局发生变化时,图像似乎“摆动”而不是围绕其中心点旋转。这看起来很奇怪,我看到许多具有这种分页的应用程序已经在图像视图上实现了平滑的布局更改动画。我如何实现这一目标?
代码是这样的:
viewDidLoad
{
// Set up scrollview subviews and their content offsets based on NSArray
// Set up orientation change listener
}
orientationChangeListener
{
UIImageView *iv = [self.ivScrollView.subviews objectAtIndex: self.ivPager.currentPage];
self.ivScrollView.layer.anchorPoint = iv.layer.anchorPoint;
[self.ivScrollView setContentOffset: CGPointMake(self.ivScrollView.frame.size.width * self.current, 0.0) animated:NO
];
switch(orientation){
case portrait:
// update scrollview's subview sizes and content offsets
// code to position the image appropriately based on screen dimensions
break;
case landscapeLeft:
// update scrollview's subview sizes and content offsets
// code to position the image appropriately based on screen dimensions
break;
case landscapeRight:
// update scrollview's subview sizes and content offsets
// code to position the image appropriately based on screen dimensions
break;
}
}
我希望这能给你这个想法。:)