找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 153|回复: 0

swift5 如何实现这样的布局,求高手指点一下

[复制链接]

310

主题

0

回帖

956

积分

管理员

积分
956
发表于 2023-12-4 12:04:39 | 显示全部楼层 |阅读模式

scrollView
直接用个动画就好了吧
superview.frame: screen.boundsimageview.frame: screen.bounds.insets(x: -50, y: 0).offset(x: 50, y: 0)uiview.animate(duration: 60) { imageview.frame = imageview.frame.offset(x: 50, y: 0) }
scrollView 里放个 UIImageView ,动画块里更新 contentOffset
好奇 滚动完了 会停止吗。还是 会循环滚动啊?
@chchengeng 滚完了就进里面了,类似开机画面、启动页这种
用 CADisplayLink 处理 frame 就行了
可以用 rive ,前段时间接触了一下,,各种动画都能做,还是很强大的
@neptuno https://rive.app/这动画工具好强大 免费版也能用很多功能
lottie 这个了解下
如果 swiftUI 开发的话原生代码就能实现
```swiftimport UIKitclass ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad()  let screenBounds = UIScreen.main.bounds  let imageView = UIImageView(image: UIImage(named: "24110307_5")) view.addSubview(imageView) let imageW = screenBounds.width + 100 imageView.frame = CGRect(x: 0, y: 0, width: imageW, height: screenBounds.height)   //方式 1// UIView.animate(withDuration: 4) {// imageView.frame = CGRect(x: -100, y: 0, width: imageW, height: screenBounds.height)// } completion: { isFinished in// if isFinished{// print("结束")// }// } //方式 2: let animation = CABasicAnimation() animation.keyPath = "transform.translation.x" animation.fromValue = 0 animation.toValue = -100 animation.duration = 4 animation.isRemovedOnCompletion = false animation.fillMode = .forwards imageView.layer.removeAllAnimations() imageView.layer.add(animation, forKey: nil)  }}```
@justin2018 是的,自己的 app 可以采用这种,真的能省很多时间
讲道理这里应该用动画或者放个视频吧,方便后台更换,原生实现可以但不太好。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|鲜于璜碑

GMT+8, 2024-7-27 18:24 , Processed in 0.127581 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表