IOS 개발 기본

Yoon Yeoung-jin·2022년 3월 9일
0

iOS 개발

목록 보기
3/11

//
//  ViewController.swift
//  reviewProject
//
//  Created by yoon-yeoungjin on 2022/03/09.
//

import UIKit

/*
  * @IBOutlet: 화면이랑 연결되어있는 변수임을 나타냄.
  * @IBAction: 해당 버튼을 눌렀을때 실행됨을 나타냄.
 */

class ViewController: UIViewController {

    @IBOutlet weak var testButton: UIButton!    /* 해당 버튼의 UI 설정을 만질 수 있는 객체 생성 */
    
    @IBAction func doSometing(_ sender: Any) {  /* 버튼을 클릭시 수행할 함수 */
        testButton.backgroundColor = .orange
        
        let storyboard = UIStoryboard(name: "Main", bundle: nil)    /* 해당 스토리보드의 객체를 받아옴. */
        /* 해당 스토리보드에서 내가 새롭게 만든 ViewController에 대한 인스턴스를 가져옴 */
        let detailVCStoryboard = storyboard.instantiateViewController(withIdentifier: "DetailVC") as! DetailVC
        
        /* 해당 인스턴스를 보여줌 */
        self.present(detailVCStoryboard, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        testButton.backgroundColor = UIColor.red
    }

}

class DetailVC: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.dismiss(animated: true)
    }
    
}



profile
신기한건 다 해보는 사람

0개의 댓글