【问题标题】:CGAffineTransformIdentity different with iOS8 and XCode6 (Without Autolayout)CGAffineTransformIdentity 与 iOS8 和 XCode6 不同(没有自动布局)
【发布时间】:2014-10-16 16:53:46
【问题描述】:

我有一个动画来添加一个子视图,使它看起来好像来自用户触摸的内部,然后填满整个屏幕。

同样,当 iOS 应用从用户触摸的地方打开时..

- (void) showView : (UIView *) theview : (CGPoint) thepoint {
    CGPoint c = thepoint;
    CGFloat tx = c.x - floorf(theview.center.x) + 10;
    CGFloat ty = c.y - floorf(theview.center.y) + 100;

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
                         // Transforms
                         CGAffineTransform t = CGAffineTransformMakeTranslation(tx, ty);
                         t = CGAffineTransformScale(t, 0.1, 0.1);
                         theview.transform = t;
                         theview.layer.masksToBounds = YES;
                         [theview setTransform:CGAffineTransformIdentity];

                     }
                     completion:^(BOOL finished) {
                     }];
}

上面的代码做了,直到iOS8..在XCode5.1(iOS7 SDK)下构建

但从 iOS8 SDK、XCode6 开始,行为完全不同

ZOOM 现在的行为很奇怪。我终于能够在 iOS8 中发现 CGAffineTransformIdentity 的行为错误(或者我使用错误?)..

我看到很多人有这个问题,但他们提到了 AutoLayout。我所有的视图都是以编程方式创建的。我们不使用 nib 文件。(IB)

如何使用 XCode 6 进行这项工作?

【问题讨论】:

    标签: ios objective-c ios8 xcode6 cgaffinetransform


    【解决方案1】:

    经过几个小时的努力,我想出了一个解决方案。我只是将它发布给未来的用户。

    - (void) showView : (UIView *) theview : (CGPoint) thepoint {
    
        CGPoint c = thepoint;
        CGFloat tx = c.x - (floorf(theview.center.x)) ;
        CGFloat ty = c.y - (floorf(theview.center.y));
    
        /* The transformation now  is before the animation block */
        CGAffineTransform t = CGAffineTransformMakeTranslation(tx, ty);
        t = CGAffineTransformScale(t, 0.1, 0.1);
        theview.transform = t;
        theview.layer.masksToBounds = YES;
    
        /* Animate only the CGAffineTransformIdentity */
        [UIView animateWithDuration:0.8
                              delay:0.0
                            options:UIViewAnimationOptionCurveEaseIn
                         animations:^{
                                        theview.layer.masksToBounds = YES;
                                        [theview setTransform:CGAffineTransformIdentity];
                                      }
                         completion:^(BOOL finished) {
                              }];
    }
    

    但我不知道,为什么它以前适用于 iOS7 SDK 而不是适用于新的 iOS8 SDK。!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-23
      • 2015-03-15
      • 1970-01-01
      • 2016-03-30
      • 1970-01-01
      • 2015-02-26
      • 1970-01-01
      相关资源
      最近更新 更多