swift5 如何实现这样的布局,求高手指点一下 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
TOTOP
11.88D
V2EX    iDev

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

  •  
  •   TOTOP 2022 年 6 月 30 日 6742 次点击
    这是一个创建于 1291 天前的主题,其中的信息可能已经有所发展或是发生改变。
    上面的是一张长图,不是视频,向左自动滚动。

    14 条回复    2022-07-01 10:59:59 +08:00
    MX123
        1
    MX123  
       2022 年 6 月 30 日
    scrollView
    InternetExplorer
        2
    InternetExplorer  
       2022 年 6 月 30 日
    直接用个动画就好了吧
    Building
        3
    Building  
       2022 年 6 月 30 日 via iPhone   1
    superview.frame: screen.bounds
    imageview.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) }
    Freeego
        4
    Freeego  
       2022 年 6 月 30 日   1
    scrollView 里放个 UIImageView ,动画块里更新 contentOffset
    chchengeng
        5
    chchengeng  
       2022 年 6 月 30 日
    好奇 滚动完了 会停止吗。还是 会循环滚动啊?
    TOTOP
        6
    TOTOP  
    OP
       2022 年 6 月 30 日
    @chchengeng 滚完了就进里面了,类似开机画面、启动页这种
    365473321
        7
    365473321  
       2022 年 6 月 30 日   1
    用 CADisplayLink 处理 frame 就行了
    neptuno
        8
    neptuno  
       2022 年 6 月 30 日   1
    可以用 rive ,前段时间接触了一下,,各种动画都能做,还是很强大的
    justin2018
        9
    justin2018  
       2022 年 6 月 30 日   1
    @neptuno

    https://rive.app/

    这动画工具好强大 免费版也能用很多功能
    zjw7sky
        10
    zjw7sky  
       2022 年 6 月 30 日   1
    lottie 这个了解下
    icebarley
        11
    icebarley  
       2022 年 6 月 30 日
    如果 swiftUI 开发的话原生代码就能实现
    V2SuperUser
        12
    V2SuperUser  
       2022 年 7 月 1 日   1
    ```swift
    import UIKit

    class 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)

    }

    }
    ```
    neptuno
        13
    neptuno  
       2022 年 7 月 1 日
    @justin2018 是的,自己的 app 可以采用这种,真的能省很多时间
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2645 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 04:01 PVG 12:01 LAX 20:01 JFK 23:01
    Do have faith in what you're doing.
    ubaomsnsnddmindexpchomeyahoorakutenmypapermeadowduckbidyahooyoubaozxmzxmasdabnvcgcvbfgdfscvmmhjkxxddcyybgbzznbnccubaouaituacvGXCVETGDGYHFGBCVBFJFHCBRECBCGDGET54WRWRRWERWREWWRWERRWERSDGEWSFDSFSFfbbsubaofhddfgewrdgdfewwrewwretruyutututdfgfgdgdfgtetgdfgtdfgdert4gdfggwr235wer3wevsdfsdfgdfertxcvsdfrwerhfddfgcvbrwfafbdfhjghbmnlghrtygfdscxvxcvxcsvdasfdffgdcvsdftertsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfshasha9178shasha9178shasha9178shasha9178shasha9178liflif2liflif2liflif2liflif2liflif2liblib3liblib3liblib3liblib3liblib3zhazha444zhazha444zhazha444zhazha444zhazha444dende5dendedendendenden2denden21fenfen9fenf619fen619fenfe9fe619sdfsdfsdfsdfsdfzhazh90zhazh0zhaa50zha90zh590zhozhozzhozhzhozhozhozho2lislislls95lili95lils5liss9sdf0ty987sdft876sdft9876sdf09876sd0t9876sdf0ty98sdf0976sdf0ty986sdf0ty96sdf0t76sdf0876df0ty98sf0t876sd0ty76sdy76sdf76sdf0t76sdf0ty9sdf0ty98sdf0ty987sdf0ty98sdf6676sdf876sd876sd876sdf6sdf6sdf9876sdf0tsdf06sdf0ty9776sdf0ty9776sdf0ty76sdf8876sdf0tsd6sdf06s688876sd688sdf86
    LINAICAI
        14
    LINAICAI  
       2022 年 7 月 1 日   1
    讲道理这里应该用动画或者放个视频吧,方便后台更换,原生实现可以但不太好。