// Set light status bar //////////////////////////////////////////////////////////////////////////////// // In the plist file, set `View controller-based status bar appearance` to `NO` // Then in viewDidLoad() UIApplication.sharedApplication().statusBarStyle = .LightContent // Make a scroll view with a big image scroll //////////////////////////////////////////////////////////////////////////////// // Tell the scrollView to be the same size as the imageView. scrollView.contentSize = imageView.frame.size // Or, set it to a pixel size. scrollView.contentSize = CGSize(width:375, height:1857) // Control a child view controller from a parent. //////////////////////////////////////////////////////////////////////////////// // Define the first `[0]` of the child view controllers with the class name // ChildViewControllerClassName as a variable childVC. // Won't always need the `self.` let childVC = self.childViewControllers[0] as! ChildViewControllerClassName // put `childVC.` before the var you want to control from the child VC. childVC.thingToControl.alpha = 1 // Go Back in Code //////////////////////////////////////////////////////////////////////////////// // Dismiss a modal dismissViewControllerAnimated(true, completion: nil) // Go back in the history stack. navigationController!.popViewControllerAnimated(true) // Do stuff when going back to a view //////////////////////////////////////////////////////////////////////////////// // viewDidLoad() only runs the first time a view loads. If you push the pop a // view and want to run some code try viewDidAppear() or viewWillAppear() override func viewDidAppear(animated: Bool) { } // Set scroll position //////////////////////////////////////////////////////////////////////////////// let scrollTo = CGPointMake(0.0, 57.0) scrollView.setContentOffset(scrollTo, animated: true) // In viewDidLoad() to hide a search bar or something like that. // Pass a variable on Segue //////////////////////////////////////////////////////////////////////////////// // In the view controller that I 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 } // Autolayout getting f-d up? //////////////////////////////////////////////////////////////////////////////// self.automaticallyAdjustsScrollViewInsets = false // in view did load // Get scroll position //////////////////////////////////////////////////////////////////////////////// // See this commit: https://github.com/andytlr/dropbox-carousel/commit/be0ed5dcdc50491995c9e4e1d43e7e21e4ae7dfa // Gesture recognizer stuff //////////////////////////////////////////////////////////////////////////////// // 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) // 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 }