To make it light, put this inside the View Controller class:
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}Or to hide it completely:
override func prefersStatusBarHidden() -> Bool {
return true
}Tell the scrollView to be the same size as the imageView:
scrollView.contentSize = imageView.frame.sizeOr, set it to a pixel size:
scrollView.contentSize = CGSize(width:375, height:1857)Define the first [0] of the child view controllers with the class name ChildViewControllerClassName as a variable childVC:
let childVC = self.childViewControllers[0] as! ChildViewControllerClassNamePut childVC. before the var you want to control from the child VC:
childVC.thingToControl.alpha = 1Dismiss a modal:
dismissViewControllerAnimated(true, completion: nil)Go back in the history stack:
navigationController!.popViewControllerAnimated(true)viewDidLoad() only runs the first time a view loads. If you want to do something when you pop a view try viewDidAppear() or viewWillAppear().
override func viewDidAppear(animated: Bool) {
}let scrollTo = CGPointMake(0.0, 57.0)
scrollView.setContentOffset(scrollTo, animated: true)In the view controller that you want to receive the variable, set an empty variable and give it a type.
var emptyVariableInDestinationViewController: Bool!In Source View Controller:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
// Set the destination view controller name at the end of this line.
let destinationVC = segue.destinationViewController as! DestinationViewControllerClassName
// Give it a value at the end of this line.
destinationVC.emptyVariableInDestinationViewController = thingIWantToSetItTo
}In viewDidLoad():
self.automaticallyAdjustsScrollViewInsets = falseSee this commit.
Most common properties in a gesture. These are CGPoints, add .x or .y for axis:
let location = sender.locationInView(view)
let translation = sender.translationInView(view)
let velocity = sender.velocityInView(view)These states go inside the gesture recognizer method:
if sender.state == .Began {
// Runs once on start of gesture
}
if sender.state == .Changed {
// Runs constantly as the gesture changes
}
if sender.state == .Ended {
// Runs once when the gesture ends
}