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.size
Or, 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! ChildViewControllerClassName
Put childVC.
before the var you want to control from the child VC:
childVC.thingToControl.alpha = 1
Dismiss 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)
Name your segue by clicking on the line that connects the views in your story board. Go to the Attribues Inspector and give your segue an Indetifier, e.g. SegueName
.
performSegueWithIdentifier("SegueName", sender: self)
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 = false
See 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
}
Where you want to send the notification:
NSNotificationCenter.defaultCenter().postNotificationName("Finished Saving To Camera Roll", object: nil)
If you're sending from a non-view file, you might need to wrap it in this to make sure it's on the main thread:
dispatch_async(dispatch_get_main_queue()) {
//
}
Then add an 'observer'/listener in the view you want to know about the notification (probably in viewDidLoad):
NSNotificationCenter.defaultCenter().addObserver(self, selector: "runWhenFinishedSavingToCameraRoll", name: "Finished Saving To Camera Roll", object: nil)
Then run the function with that selector at the class level:
unc runWhenFinishedSavingToCameraRoll() {
// Tell user it finished saving
}