问题
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