菜鸟教程小白 发表于 2022-12-12 12:55:27

iOS:动画 View 移回原始位置


                                            <p><p>我正在尝试制作一个动画,以简单地将 Y 轴向上移动大约 50 个点。
动画有效,但一旦完成,它就会回到原来的位置。</p>

<pre><code>UIView* view = ;
    [UIView animateWithDuration:0.5
                        delay:0.1
                        options: UIViewAnimationOptionCurveEaseOut
                     animations:^
   {
         CGRect frame = view.frame;
         frame.origin.y = 230;
         frame.origin.x = 30;
         view.frame = frame;
   }
                     completion:^(BOOL finished)
   {
         NSLog(@&#34;Completed&#34;);

   }];
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您的布局约束将把它拉回来。这是目前非常普遍的问题。您必须修改 NSLayoutConstraint 对象以反射(reflect)对 View 的更改。 </p>

<p>例如Constraint.constant += 50;</p>

<p>搜索堆栈溢出以查找其他问题,例如您在询问之前要询问的问题。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS:动画 View 移回原始位置,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/27081318/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/27081318/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS:动画 View 移回原始位置