Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
viewContoller_4_methods_swift
//
// ViewController.swift
// Testviewcontoller
//
// Created by Ben Liu on 14/4/17.
// Copyright © 2017 Ben Liu. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
NSLog("viewDidLoad is running")
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
NSLog("viewWillAppear is running")
}
override func viewDidAppear(_ animated: Bool) {
NSLog("viewDidAppear is running")
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
NSLog("viewWillDisappear is running")
}
override func viewDidDisappear(_ animated: Bool){
NSLog("viewDidDisappear is running")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func onBtnClicked(_ sender: Any) {
let anotherView = UIViewController()
anotherView.view.backgroundColor = UIColor.red
self.present(anotherView, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.