<small id='OkPTj'></small><noframes id='OkPTj'>

    <i id='OkPTj'><tr id='OkPTj'><dt id='OkPTj'><q id='OkPTj'><span id='OkPTj'><b id='OkPTj'><form id='OkPTj'><ins id='OkPTj'></ins><ul id='OkPTj'></ul><sub id='OkPTj'></sub></form><legend id='OkPTj'></legend><bdo id='OkPTj'><pre id='OkPTj'><center id='OkPTj'></center></pre></bdo></b><th id='OkPTj'></th></span></q></dt></tr></i><div id='OkPTj'><tfoot id='OkPTj'></tfoot><dl id='OkPTj'><fieldset id='OkPTj'></fieldset></dl></div>
  1. <tfoot id='OkPTj'></tfoot><legend id='OkPTj'><style id='OkPTj'><dir id='OkPTj'><q id='OkPTj'></q></dir></style></legend>
    • <bdo id='OkPTj'></bdo><ul id='OkPTj'></ul>
    1. 为 UIImage 或 UIImageView 设置动画?

      时间:2024-04-14
        <bdo id='6i8Yl'></bdo><ul id='6i8Yl'></ul>

        <small id='6i8Yl'></small><noframes id='6i8Yl'>

        <tfoot id='6i8Yl'></tfoot>

        <legend id='6i8Yl'><style id='6i8Yl'><dir id='6i8Yl'><q id='6i8Yl'></q></dir></style></legend>

            <i id='6i8Yl'><tr id='6i8Yl'><dt id='6i8Yl'><q id='6i8Yl'><span id='6i8Yl'><b id='6i8Yl'><form id='6i8Yl'><ins id='6i8Yl'></ins><ul id='6i8Yl'></ul><sub id='6i8Yl'></sub></form><legend id='6i8Yl'></legend><bdo id='6i8Yl'><pre id='6i8Yl'><center id='6i8Yl'></center></pre></bdo></b><th id='6i8Yl'></th></span></q></dt></tr></i><div id='6i8Yl'><tfoot id='6i8Yl'></tfoot><dl id='6i8Yl'><fieldset id='6i8Yl'></fieldset></dl></div>

                  <tbody id='6i8Yl'></tbody>

              • 本文介绍了为 UIImage 或 UIImageView 设置动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试为图像的高度设置动画(从 0 像素高度到 480 像素)以创建自上而下渲染的图像效果.

                I'm trying to animate an image's height (from height of 0 pixels to 480 pixels) to create the effect of the image being rendered top-down.

                使用 UIImageView 我注意到它在 Interface Builder 中看起来是正确的.但是当它在模拟器中运行时,大小(宽度和高度)总是设置为图像的大小;这意味着,如果我将图像视图的高度设置为原始高度的 50%,图像仍会以全高呈现.

                With an UIImageView i noticed that it appears correct in the Interface Builder. But when it runs in the simulator the size (width and height) is always set to whatever the size of the image is; meaning, if I set the height of the image view to be 50% the original height, the image is still rendered in full height.

                我也试过用 UIImage 来做这个效果.然而,虽然图像的大小看起来是正确的,但图像会被缩放以反映大小/纵横比.

                I also tried do this effect with an UIImage. However, although the size of the image appears correct, the image is scaled to reflect the size/aspect-ratio.

                问题:如何在不缩放图像的同时实现这种动态大小(即图像大小的动画)?我考虑过使用 CGImageCreateWithMask,但我很确定这会产生巨大的性能问题.

                Question: How can i achieve this dynamic sizing (i.e. animation of an image's size) while NOT scaling the image? I thought about using CGImageCreateWithMask, but im pretty sure that would create huge performance hiccups.

                * 更新 *

                我正在寻找的效果是这样的:通过使图像的高度从上到下(就像一组百叶窗被拉到窗户上)来为图像设置动画.此图像无法缩放(因为它会失去看起来像盲人"的视觉效果).此图像还必须在另一个图像之上渲染.所以总共有 2 张图片.

                The effect that im looking for is this: Animate an image by making it grow in height, from to-down (like a set of blinds being pulled on a window). This image cannot be scaled (as it would lose the visual effect of looking like a "blind"). This image must also be rendered on top of another image. So there are 2 images total.

                * 答案 *

                对于最顶部的图像视图,我将内容模式设置为顶部(因此它不会缩放).然后在代码中,我将 clipsToBounds 设置为 True.现在我可以为最顶部的 imageview 高度设置动画,从而给我想要的效果.

                For the top-most imageview, i set the content mode to Top (so it doesnt scale). Then in code, i set the clipsToBounds to True. Now i am able to animate the top-most imageview height thus giving me the effect i am looking for.

                推荐答案

                正如原帖中提到的,这是我似乎偶然发现的答案:

                As mentioned in the original post, here is the answer i seem to have stumbled upon:

                对于最顶部的图像视图,我将内容模式设置为顶部(因此它不会缩放).然后在代码中,我将 clipsToBounds 设置为 True.现在我可以为最顶部的 imageview 高度设置动画,从而给我想要的效果.

                For the top-most imageview, i set the content mode to Top (so it doesnt scale). Then in code, i set the clipsToBounds to True. Now i am able to animate the top-most imageview height thus giving me the effect i am looking for.

                这篇关于为 UIImage 或 UIImageView 设置动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:为 UIImageView 实现 UITouchDown 下一篇:UIImageView+animatedGIF 总是 LOOPS

                相关文章

                <i id='wSxZT'><tr id='wSxZT'><dt id='wSxZT'><q id='wSxZT'><span id='wSxZT'><b id='wSxZT'><form id='wSxZT'><ins id='wSxZT'></ins><ul id='wSxZT'></ul><sub id='wSxZT'></sub></form><legend id='wSxZT'></legend><bdo id='wSxZT'><pre id='wSxZT'><center id='wSxZT'></center></pre></bdo></b><th id='wSxZT'></th></span></q></dt></tr></i><div id='wSxZT'><tfoot id='wSxZT'></tfoot><dl id='wSxZT'><fieldset id='wSxZT'></fieldset></dl></div>

                  <small id='wSxZT'></small><noframes id='wSxZT'>

                  • <bdo id='wSxZT'></bdo><ul id='wSxZT'></ul>
                  <tfoot id='wSxZT'></tfoot>

                    <legend id='wSxZT'><style id='wSxZT'><dir id='wSxZT'><q id='wSxZT'></q></dir></style></legend>