zoukankan      html  css  js  c++  java
  • UITabbarItem imageview 实现点击有放大然后还原的动画效果

    在UITabBarController代理方法中添加动画,先通过KVC获取UIControl,然后在获取上面的UITabBarSwappableImageView,最后将动画添加到imageview的layer上。
    #pragma mark UITabBarControllerDelegate的代理方法
    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    {
        UIControl*tabBarButton = [viewController.tabBarItem valueForKey:@"view"];
        if (tabBarButton) {
            UIImageView * tabBarSwappableImageView = [tabBarButton valueForKey:@"info"];
            if ([tabBarSwappableImageView isKindOfClass:NSClassFromString(@"UITabBarSwappableImageView")]) {
                CAKeyframeAnimation * animation;
                animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
                animation.duration = 0.3;
                animation.removedOnCompletion = YES;
                animation.fillMode = kCAFillModeForwards;
                NSMutableArray *values = [NSMutableArray array];
                [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
                [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
                [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
                animation.values = values;
                [tabBarSwappableImageView.layer addAnimation:animation forKey:nil];
            }
        }
        return YES;
    }

  • 相关阅读:
    Leetcode: Reverse Integer
    Leetcode: Two Sum
    Leetcode: Path Sum
    make distclean
    makefile 中 foreach
    nor flash 和 nand flash
    端口(port)的安全模式(security mode)
    单片机入门(二)
    单片机入门(一)
    kworker
  • 原文地址:https://www.cnblogs.com/weipeng168/p/10270409.html
Copyright © 2011-2022 走看看