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;
    }

  • 相关阅读:
    fastjson反序列化漏洞研究(上)
    csv注入复现代码
    day24-python之面向对象
    day23-python之日志 re模块
    day22-python之模块
    day21-python模块
    day20-python之装饰器
    day18-python之迭代器和生成器
    day17-python之文件操作
    day16-python之函数式编程匿名函数
  • 原文地址:https://www.cnblogs.com/weipeng168/p/10270409.html
Copyright © 2011-2022 走看看