iOS 研究工具包调查(快速)

标签 ios swift uiimageview researchkit

如何为我的 ResearchKit 调查添加自定义背景?

我试过:

taskViewController.view.backgroundColor = UIColor(patternImage: UIImage(named:imageName))

还有:

    taskViewController.view.backgroundColor = UIColor.clearColor()
    let backgroundImage = UIImage(named: "Background")
    let imageView = UIImageView(image: backgroundImage)
    taskViewController.view.addSubview(imageView)
    taskViewController.view.sendSubviewToBack(imageView)

最佳答案

每个单独的步骤 View Controller 都需要添加背景。有一个委托(delegate)方法 taskViewController:stepViewControllerWillAppear:,您可以使用它在呈现之前拦截步骤 View Controller 并根据需要修改其 View 层次结构。请注意,许多步骤在其 View 层次结构中包含 TableView 或 ScrollView ,您需要考虑这些。

如果您只需要背景颜色,您可以尝试使用 UIView appearanceWhenContainedIn 来更改每个步骤 View Controller 下方整个层次结构的背景颜色。

关于iOS 研究工具包调查(快速),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31148143/

相关文章:

ios - 存档提交已完成,但出现警告 : Configuration Home Partition has fewer than 100 megabytes free

ios - 如何从应用程序扩展更新的 sqlite 文件中重新加载主应用程序中的 CoreData 数据?

ios - 如何在填充UIImageViews的NSArray中搜索某个图像属性?

ios - 提高透明图像绘制性能

ios - 如何使用自动调整高度的 SnapKit 以编程方式创建 UITableViewCell?

ios - 如何让 MSCollectionViewCalendarLayout 的示例正常工作

ios - 当我们在ios中选择最后一个按钮时如何选择所有按钮

ios - CLLocation 时间戳始终为零

ios - 如何以编程方式在 SceneKit 中围绕立方体包装 png 纹理

ios - UIImageView/UIView 的自动布局纵横比