ios - 具有动态内容的分页滚动

标签 ios swift uiscrollview

我有一个 imageView,我想在其上显示一些内容。但是我希望用户能够在图像上的不同内容之间滚动。该内容是一个标签,其中标签文本是从数组确定的?我如何创建这样的东西,您还可以从数组中的第一个对象向后滚动到最后一个对象?

viewDidLoad

    let firstFrame : CGRect = CGRectMake(0, 0, self.view.frame.width, self.view.frame.height-100-64)

    var bigFrame : CGRect = firstFrame

    bigFrame.size.width *= 2.0

    scrollView = UIScrollView(frame: firstFrame)
    self.cameraView.addSubview(scrollView!)

    let firstView : UIView = UIView(frame: firstFrame)
    firstView.backgroundColor = UIColor.redColor()
    scrollView!.addSubview(firstView)
    let secondView : UIView = UIView(frame: firstFrame)
    scrollView!.addSubview(secondView)
    scrollView!.pagingEnabled = true
    scrollView!.contentSize = bigFrame.size

    scrollView?.hidden = true

进一步说明

所以基本上我有一个像这样的数组

var textArray = ["#COYS", "#SPURS", "#DELLEALLI"]

然后我的 View 中有一个 UIImageView ,我基本上希望能够从顶部的数组中滚动不同的文本。不过,我也希望它能够,以便您可以滚动后台单词,并且在这个 casw 中它将从 textArray[0]textArray[2]

enter image description here

最佳答案

一种选择是使用页面 View Controller 。看看我的例子: https://www.dropbox.com/sh/mezxx53rd3bvw7g/AAB6PuUIGZwccgxOsjLPfvcfa?dl=0

关于ios - 具有动态内容的分页滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33674830/

相关文章:

swift - Swift 2 中 for 循环的奇怪行为

cocoa - 求和 UIView subview 属性的 KVC 路径是什么?

ios - UICollectionView 无限滚动 : reuses index paths and clears content

ios - iOS 推送通知的位置请求(当应用程序未在后台运行时)

ios - 如何使用 Core Data 允许歌曲在播放列表中重新排列?

ios - 允许在 UIWebView 中访问位置

iPhone App如何以编程方式检测 ScrollView 的滚动?

ios - ios:UIAlertView在for循环执行之前立即显示

ios - 如何将 "Open in.."函数添加到自定义 UIWebview?

swift - Swift 中运算符重载的多态性