ImageView에 아웃렛 변수와 액션 함수 추가하기

Posted on 2021-09-02 by GKSRUDTN99
Swift&Xcode Xcode ImageView

이미지 뷰 객체와 버튼 객체, 스위치 객체를 연결할 아웃렛 변수와 액션 함수를 추가한다.
앞의 포스트를 참고하여 Assistant 창을 연다.

이미지 뷰에 아웃렛 변수 추가하기

  1. 이미지 뷰를 마우스 오른쪽 버튼으로 클릭한뒤 클래스 선언부 바로 아레에 아웃렛 변수로 연결한다.

    • Connection: Outlet
    • Name: imgView
    • Type: UIImageView
    • Storage: Strong
  2. 확대/축소 버튼의 아웃렛 변수 추가하기

    • Connection: Outlet
    • Name: btnResize
    • Type: UIButton
    • Storage: Strong
  3. 버튼에 대한 액션 추가하기

    • Connection: Action
    • Name: btnResizeImage
    • Type: UIButton
    • Event, Arguments는 그대로 둔다.
  4. 스위치에 대한 액션 함수 추가하기

    • Connection: Action
    • Nmae: switchImageOnOff
    • Type: UISwitch
    • Event, Arguments는 그대로 둔다.
//
//  ViewController.swift
//  ImageView
//
//  Created by 한경수 on 2021/09/02.
//

import UIKit

class ViewController: UIViewController {
    @IBOutlet var imgView: UIImageView!

    @IBOutlet var btnResize: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


    @IBAction func btnResizeImage(_ sender: UIButton) {
    }
    @IBAction func switchImageOnOff(_ sender: UISwitch) {
    }
}