标签: animation

如何为约束更改设置动画?

我正在更新旧的应用程序,AdBannerView当没有广告时,它会从屏幕上滑落.当有广告时,它会在屏幕上滑动.基本的东西.

旧样式,我在动画块中设置框架.新风格,我有一个IBOutlet确定Y位置的约束,在这种情况下,它与superview底部的距离,并修改常量.

- (void)moveBannerOffScreen {
    [UIView animateWithDuration:5 animations:^{
        _addBannerDistanceFromBottomConstraint.constant = -32;
    }];
    bannerIsVisible = FALSE;
}

- (void)moveBannerOnScreen {
    [UIView animateWithDuration:5 animations:^{
        _addBannerDistanceFromBottomConstraint.constant = 0;
    }];
    bannerIsVisible = TRUE;
}
Run Code Online (Sandbox Code Playgroud)

横幅移动,完全符合预期,但没有动画.

更新:我重新观看了WWDC12视频" 掌握自动布局的最佳实践 ",其中包括动画.它讨论了如何使用更新约束AdBannerView.

在此输入图像描述 在此输入图像描述

我尝试使用以下代码,但得到完全相同的结果.

- (void)moveBannerOffScreen {
    _addBannerDistanceFromBottomConstraint.constant = -32;
    [UIView animateWithDuration:2 animations:^{
        [self.view setNeedsLayout];
    }];
    bannerIsVisible = FALSE;
}

- (void)moveBannerOnScreen {
    _addBannerDistanceFromBottomConstraint.constant = 0;
    [UIView animateWithDuration:2 animations:^{
        [self.view setNeedsLayout];
    }];
    bannerIsVisible = TRUE;
}
Run Code Online (Sandbox Code Playgroud)

在旁注中,我已经多次检查过,这是在主线程上执行的.

animation objective-c ios autolayout ios6

934
推荐指数
9
解决办法
27万
查看次数

如何使用jQuery创建"Please Wait,Loading ..."动画?

我想在我的网站上放置一个"请等待,加载"旋转圆圈动画.我应该如何使用jQuery实现这一目标?

jquery animation

564
推荐指数
12
解决办法
102万
查看次数

Android:展开/折叠动画

假设我有一个垂直linearLayout:

[v1]
[v2]
Run Code Online (Sandbox Code Playgroud)

默认情况下,v1具有visibily = GONE.我想用扩展动画展示v1并同时向下推v2.

我试过这样的事情:

Animation a = new Animation()
{
    int initialHeight;

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        final int newHeight = (int)(initialHeight * interpolatedTime);
        v.getLayoutParams().height = newHeight;
        v.requestLayout();
    }

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
        initialHeight = height;
    }

    @Override
    public boolean willChangeBounds() {
        return true;
    }
};
Run Code Online (Sandbox Code Playgroud)

但是使用这个解决方案,动画开始时我会闪烁.我认为这是由v1在应用动画之前显示完整大小引起的.

使用javascript,这是一行jQuery!用android做任何简单的方法吗?

animation android

435
推荐指数
18
解决办法
26万
查看次数

Android上视图背景颜色的动画更改

如何动画Android上视图背景颜色的变化?

例如:

我有一个红色背景颜色的视图.视图的背景颜色变为蓝色.如何在颜色之间进行平滑过渡?

如果无法通过视图进行此操作,则欢迎使用其他选项.

animation android view background-color

313
推荐指数
16
解决办法
21万
查看次数

如何在元素上进行多个CSS转换?

这是一个非常直截了当的问题,但我找不到关于CSS过渡属性的非常好的文档.这是CSS片段:

    .nav a
{
    text-transform:uppercase;
    text-decoration:none;
    color:#d3d3d3;
    line-height:1.5 em;
    font-size:.8em;
    display:block;
    text-align:center;
    text-shadow: 0 -1.5em 0 rgba(255, 255, 255, 0.15);
    -webkit-transition: color .2s linear;
    -moz-transition: color .2s linear;
    -o-transition: color .2s linear;
    transition: color .2s linear;
    -webkit-transition: text-shadow .2s linear;
    -moz-transition: text-shadow .2s linear;
    -o-transition: text-shadow .2s linear;
    transition: text-shadow .2s linear;
}

.nav a:hover
{
    color:#F7931E;
    text-shadow: 0 1.5em 0 rgba(247, 147, 30, 0.15);
}
Run Code Online (Sandbox Code Playgroud)

如您所见,过渡属性会相互覆盖.就目前而言,文本阴影将动画,但不是颜色.我怎样让他们同时动画?谢谢你的回答.

css animation css3 css-transitions

306
推荐指数
4
解决办法
26万
查看次数

使用向上/向下滑动动画显示和隐藏视图

我有一个LinearLayout我希望显示或隐藏的内容Animation,只要我改变其可见性,就会向上或向下推动布局.

我在那里看到了一些样品,但它们都不适合我的需要.

我为动画创建了两个xml文件,但是当我更改a的可见性时,我不知道如何启动它们LinearLayout.

animation android android-animation

287
推荐指数
9
解决办法
33万
查看次数

UIView无限360度旋转动画?

我正在尝试旋转UIImageView360度,并在线查看了几个教程.我可以让他们都没有工作,没有UIView停止,或跳到一个新的位置.

  • 我怎样才能做到这一点?

我尝试过的最新事情是:

[UIView animateWithDuration:1.0
                      delay:0.0
                    options:0
                 animations:^{
                     imageToMove.transform = CGAffineTransformMakeRotation(M_PI);
                 } 
                 completion:^(BOOL finished){
                     NSLog(@"Done!");
                 }];
Run Code Online (Sandbox Code Playgroud)

但是如果我使用2*pi,它根本不会移动(因为它是相同的位置).如果我尝试做pi(180度),它可以工作,但如果我再次调用该方法,它会向后旋转.

编辑:

[UIView animateWithDuration:1.0
                      delay:0.0
                    options:0
                 animations:^{
                     [UIView setAnimationRepeatCount:HUGE_VALF];
                     [UIView setAnimationBeginsFromCurrentState:YES];
                     imageToMove.transform = CGAffineTransformMakeRotation(M_PI);
                 } 
                 completion:^(BOOL finished){
                     NSLog(@"Done!");
                 }];
Run Code Online (Sandbox Code Playgroud)

也不起作用.它会转到180度数,暂停一瞬间,然后在重新0开始之前重新设置为度数.

animation core-animation objective-c uiview ios

244
推荐指数
13
解决办法
15万
查看次数

如何停止动画(cancel()不起作用)

我需要停止正在运行的翻译动画.该.cancel()方法Animation无效; 无论如何,动画一直持续到最后.

你如何取消正在运行的动画?

animation android

227
推荐指数
4
解决办法
13万
查看次数

CSS3旋转动画

<img class="image" src="" alt="" width="120" height="120">
Run Code Online (Sandbox Code Playgroud)

无法让这个动画图像工作,它应该做360度旋转.

我想下面的CSS有些不对劲,因为它只是保持不动.

.image {
    float: left;
    margin: 0 auto;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin-top: -60px;
    margin-left: -60px;

    -webkit-animation-name: spin;
    -webkit-animation-duration: 4000ms;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;

    -moz-animation-name: spin;
    -moz-animation-duration: 4000ms;
    -moz-animation-iteration-count: infinite;
    -moz-animation-timing-function: linear;

    -ms-animation-name: spin;
    -ms-animation-duration: 4000ms;
    -ms-animation-iteration-count: infinite;
    -ms-animation-timing-function: linear;

    animation-name: spin;
    animation-duration: 4000ms;
    animation-iteration-count: infinite;
    animation-timing-function: linear;

    @-ms-keyframes spin { 
        from { 
            -ms-transform: rotate(0deg); 
        } to { 
            -ms-transform: rotate(360deg); 
        }
    }
    @-moz-keyframes spin { 
        from { …
Run Code Online (Sandbox Code Playgroud)

animation image rotation css3

224
推荐指数
3
解决办法
62万
查看次数

如何在基于导航的应用程序中更改Push和Pop动画

我有一个基于导航的应用程序,我想改变推动和弹出动画的动画.我该怎么办?

编辑2018

这个问题有很多答案,现在已经有一段时间了,我已经重新选择了我认为现在最相关的答案.如果有人不这么认为,请在评论中告诉我

animation uinavigationcontroller ios

213
推荐指数
14
解决办法
18万
查看次数