- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我怎样才能在单个 View Controller 上获得过渡动画
效果(如页面幻灯片) - 这样看起来我正在过渡到一个新页面/ Controller
(尽管在同一个 View 中只有数据发生变化)?
例如:我有一个 UIViewController
,它有 Previous 和 Next 按钮。单击下一步这些按钮时,不同的标题和图像将显示在“相同”UIViewController
上。
我知道这可以通过 UIPageViewController
来完成 - 但我是 iOS 的新手,发现以这种方式实现相当困难。
最佳答案
我也有同样的情况。但是因为我们不希望有复杂的幻灯片动画,所以我不会实现 UIPageViewController。相反,我提出了以下解决方案:
想法是创建快照 View 并在其上启动动画,同时在用户开始滑动时使用新数据更新 View 。通过这样做,我们可以让人感觉我们正在转换到另一个 View 。
下面的示例代码是用 Xamarin.iOS 编写的,但我相信它可以很容易地转移到 Swift/Obj-C:
UIView snapShotView = View.SnapshotView(false); // Create snapshot for the view (I assumed that View is the container)
View.Add(snapShotView);
snapShotView.Frame = View.Frame; //Add snapshot and set its frame so the snapshot will be overlapped the original View
CGRect snapshotEndFrame = snapShotView.Frame;
snapshotEndFrame.X = -snapShotView.Frame.Width;
UIView.Animate(0.7, 0, UIViewAnimationOptions.CurveEaseInOut,
() =>
{
//Load new data to your View
...
//Animate the snapshot view
snapShotView.Frame = snapshotEndFrame;
},
() =>
{
//Remove Snap Shot View after doing animation to prevent memory leak
snapShotView.RemoveFromSuperview();
snapShotView.Dispose();
});
关于iOS swift : Transition Animation on same View Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30466168/
尝试添加动画以替换 fragment 时抛出该异常。根据这个答案,stackoverflow ,过渡框架不能应用于 fragment ,但这篇文章表明你可以 How to use Material T
还有其他一些类似的问题,但都涉及 Android 支持库。我正在使用新的 androidx 库。 将 androidx 生命周期依赖项从 2.2.0-alpha03 更新到 2.2.0-alpha04
这个问题在这里已经有了答案: What is an optional value in Swift? (15 个答案) When two optionals are assigned to an i
Tailwind 提供了多个实用程序来控制哪些 CSS 属性转换,在这些属性中有 transition 和 transition-all。 我去检查了两个类的 CSS 属性,这里它们的顺序相同。 tr
Tailwind 提供了多个实用程序来控制哪些 CSS 属性转换,在这些属性中有 transition 和 transition-all。 我去检查了两个类的 CSS 属性,这里它们的顺序相同。 tr
这是一个由两部分组成的问题: 哪种应用样式优先:CSS 中的 -webkit-transition 规则或 jQuery 中类似的 $.css() 方法? 如果我还在 jQuery 中使用 .css
我想知道为什么在 FireFox 中使用 transition: all 0.5s ease-out; 时我会看到元素上的闪烁效果(截至本文撰写时的最新版本)。很难解释,但请在此处查看实际示例:htt
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
我目前正在用 Html 制作我的第一个网站,javascript 作为前端将首先出现。 我正在尝试创建一个折叠侧边栏,当我单击顶部导航右侧的按钮时会出现该侧边栏,但我对过渡效果有疑问,因为它会将所有内
我有一个 Activity ,一次托管一个 fragment ,并在两个 fragment 之间交换。 fragment A 使用按钮启动 fragment B, fragment B 使用按钮或后退
我正在尝试创建一种效果: 光标悬停在一个框上 横杆滑出 随着滑动 Action 缓和,标题出现 光标离开方框 随着栏向后滑动,标题开始消失 横杆完成向后滑动 但是,当光标离开框时,会再次调用延迟,因此
让我提供一些背景信息:我正在构建一个选项卡式应用程序,允许用户查找和查看我们服务器上托管的一些视频。每个选项卡都以不同的方式对视频进行分组,导航栏中有一个分段控件,用户可以使用该控件更精确地对列表进行
原始问题...更新了以下工作代码: 我有一个在 ajax 加载事件期间出现的加载图像。图像通过向 body 元素添加或删除“加载”类来显示/隐藏。目前,加载图像将背景大小设置为从 0% 到 100%
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
当我继续学习前端开发和练习 Sass 优化我的 CSS 代码时,我又遇到了另一种情况。 在互联网上进行研究和教程后,我在 Sass 中设置了名为“transition”的全局混合。代码如下所示: @m
关于 Chrome 和 css 转换的问题太多了,我不确定以前是否有人问过这个问题。 我的情况是这样的:我的布局基本上是左右分页。右侧的一框内容需要显示在左侧的内容之上(这个我没有发言权,桌面和移动之
我在两个 Activity 之间的共享元素中使用了自定义 Transition。 我的转换不起作用,因为 TransitionValues 参数在 captureStartValues 和 这两种方法
我在 google Chrome 和 Safari 上运行我的应用程序,两者都兼容 webkit。我正在使用 -webkit-transition 构建一个滚动的 div。 当我将文档类型指定为 HT
以下代码在 chrome 中产生了预期的结果,即;直接向所有元素添加过渡延迟。 $('.front-nav .sub-menu').each(function() { var transiti
我是一名优秀的程序员,十分优秀!