我有一个 UIView,当用户点击它时,我想自动缩放到屏幕的大小。
我从http://cocoawithlove.com/2010/09/zoomingviewcontroller-to-animate-uiview.html获取代码
并且缩放有效,除了在缩放开始之前视图旋转 90 度。为什么会这样?
(视图在轮播中。在用户点击视图之前,设备被旋转到横向,此时轮播的视图控制器被推送到导航堆栈并显示轮播。)
代码是:
- (void)buttonTapped:(UIButton *) sender
{
NSInteger index = [self.carousel indexOfItemView:sender];
UIView *currentView = [self.carousel itemViewAtIndex: index];
UIView *proxyView = [[UIView alloc] initWithFrame:currentView.frame];
proxyView.hidden = YES;
proxyView.autoresizingMask = currentView.autoresizingMask;
[currentView.superview addSubview: proxyView];
CGRect frame = [currentView.window convertRect:currentView.frame fromView:proxyView.superview];
[currentView.window addSubview:currentView];
currentView.frame = frame;
[UIView
animateWithDuration:2.4
animations:^{
currentView.frame = currentView.window.bounds;
}];
(carousel 是 UIView 派生的对象,来自https://github.com/nicklockwood/iCarousel)
谢谢