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

  • 相关阅读:
    c#读取XML
    Javascript 自动计算生日
    Thread.currentThread()与setDaeMon(boolean c)方法
    StringBuffer类的delete()方法和deleteCharAt()方法
    getStackTrace()方法使用
    JDBC详解
    eclipse与idea路径不匹配
    Idea导入maven项目不自动识别pom.xml
    IDEA找不到或无法加载主类
    MySQL:主从复制与处从复制同步延迟
  • 原文地址:https://www.cnblogs.com/weipeng168/p/10270409.html
Copyright © 2011-2022 走看看