iOS research kit survey (swift)

淺唱寂寞╮ 提交于 2019-12-13 03:38:52

问题


how can I add a custom background to my ResearchKit survey?

I tried:

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

And:

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

回答1:


The individual step view controllers will each need the background added. There is a delegate method taskViewController:stepViewControllerWillAppear:, which you can use to intercept the step view controller before presentation and modify its view hierarchy as needed. Nite that many of the steps include a table view or scroll view in their view hierarchy, which you would need to take into account.

If all you want is background color, you could try using UIView appearanceWhenContainedIn to change background color on the whole hierarchy below each step view controller.




回答2:


What you have to do from the "viewDidLoad" from his "TaskViewController"

Objective-C:

self.background.image = [[UIImage imageNamed:@"magenta-box.png"] stretchableImageWithLeftCapWidth:20 topCapHeight:20];


来源:https://stackoverflow.com/questions/31148143/ios-research-kit-survey-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!