2014-11-04 58 views
0
UIView *timerBarView = [[UIView alloc] initWithFrame:timerRect]; 
    timerBarView.backgroundColor = [UIColor blueColor]; 
    timerBarView.alpha = 0.5; 
    [theParentView addSubview:timerBarView]; 
    [UIView animateWithDuration:duration 
          delay:0.0 
         options:UIViewAnimationOptionCurveLinear 
        animations:^{ timerBarView.transform = CGAffineTransformMakeScale(0, 1); } 
        completion:^(BOOL fin){if(fin)[timerBarView removeFromSuperview];}]; 

我敢肯定,这段代码工作,直到我更新到Xcode 6.现在timerBar根本不出现。所需的外观是一条长长的蓝色条,水平缩小到零。UIView和动画不出现

予记录的rects(之前立即上面的代码的执行)和那些似乎细:

timerRect: {{10, 252}, {362, 4}} 
theParentView.bounds: {{0, 0}, {382, 258}} 

我甚至尝试给予timerBarView一个100,100,200,50矩形,并直接将其添加到视图控制器的视图,而不是用它作为子视图。它仍然没有工作。

那么...我的timerBar在哪里? (; _;)

回答

2

是你测试这个代码在iOS 8.0+?我注意到缩放到0的动画在ios 8中不起作用,但在ios 7.0中起作用。您可以尝试设置一个非常小的值而不是0来执行动画。

+0

非常感谢。这正是问题所在! – user3925713 2014-11-04 22:21:53