- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 slider 驱动具有 2 个图像值(在此示例中)的 UIImageView 的转换但是在 UIViewPropertyAnimator
中使用 UIView.transition
(应该可以工作)它没有。我错过了什么吗?
let animator = UIViewPropertyAnimator(duration: 3.0, curve: .linear)
let crossDissolve = {
self.imageView.image = UIImage(named: "deadpool.jpg")
UIView.transition(
with: self.imageView,
duration: 4.0,
options: .transitionCrossDissolve,
animations: {},
completion: nil
)
}
animator.addAnimations(crossDissolve)
这是一个带有问题示例的 Playground ,只需将 slider 从一侧拖动到另一侧,图像就会柔和地交叉溶解
类似于:
Playground :https://www.dropbox.com/s/ix8nfxg43ij68q3/UIViewPropertyAnimator.playground.zip?dl=0
最佳答案
在提供的代码中,您没有在动画闭包中定义任何动画,我对这个 API 不是很熟悉,但我假设您会想要这样的东西。(我没有测试过这段代码)
let animator = UIViewPropertyAnimator(duration: 3.0, curve: .linear)
let crossDissolve = {
UIView.transition(
with: self.imageView,
duration: 4.0,
options: .transitionCrossDissolve,
animations: {
self.imageView.image = UIImage(named: "deadpool.jpg")
},
completion: nil
)
}
animator.addAnimations(crossDissolve)
然后您可以使用在 slider .valueChanged
事件上调用的函数来处理动画进度
slider.addTarget(self, action: #selector(sliderValueChanged(_:)), for: .valueChanged)
func sliderValueChanged(sender: UISlider) {
myAnimation.fractionComplete = CGFloat(sender.value)
}
关于ios - 无法使用 UIViewPropertyAnimator.fractionComplete 驱动 UIView.transition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51965147/
我正在尝试使用 AFNetworking 和 NSProgress 跟踪我的 HTTP 请求的进度。基本上,我的请求是一个包含文本参数和图像数据的多部分表单数据,所有这些都在一个 block 中。 这
我使用 Alamofire 框架从服务器下载图像。我需要进度下载,但我无法下载。 Alamofire.download(requestForImage, method: .post, paramete
所以我使用新的 UIViewPropertyAnimator 和 UIVisualEffectView 来实现与 Spotlight 搜索相同的效果,当您在主屏幕上向下滚动并模糊背景时。 我正在使用
我一直在关注 iOS 10 中非常酷的新 UIViewPropertyAnimator 类。它可以让您轻松执行暂停、恢复和反转飞行中的 UIView 等操作动画。过去,您必须操纵系统创建的底层 CAA
我注意到在某些情况下Progress.fractionCompleted超过 1.0 甚至重置回 0。我第一次注意到它是在使用 MultipeerConnectivity 框架时,我使用从 MCSes
我正在尝试使用 slider 驱动具有 2 个图像值(在此示例中)的 UIImageView 的转换但是在 UIViewPropertyAnimator 中使用 UIView.transition (
我有一个 NSProgress 对象树来监视涉及下载文件的数据处理。下载是使用带有后台配置的 NSURLSession 完成的。 当我启动进程时,最顶层的 NSProgress 对象报告意外的 fra
问题 在 iOS10 和 iOS11 上运行相同的代码,我的 UIViewPropertyAnimator 在更改其 .isReversed 属性后具有不同的行为。 iOS10一切正常。 iOS11出
我是一名优秀的程序员,十分优秀!