728x90
반응형
//
// ViewController.swift
// PinchGesture
//
// Created by Leo_Jang on 27/08/2020.
// Copyright © 2020 Leo_Jang. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var lblApple: UILabel!
var initialFontSize: CGFloat! // 글자 크기
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let pinch = UIPinchGestureRecognizer(target: self, action: #selector(ViewController.doPinch(_: )))
self.view.addGestureRecognizer(pinch)
}
@objc func doPinch(_ pinch: UIPinchGestureRecognizer){
if pinch.state == UIGestureRecognizer.State.began{
initialFontSize = lblApple.font.pointSize // 확대할 때 크기를 준다.
}else{
lblApple.font = lblApple.font.withSize(initialFontSize * pinch.scale) // 기본값에 *
}
}
}
반응형
'개발자 코드(Code) > Swfit' 카테고리의 다른 글
IOS) Swipe Guesture + PageControl (한 손가락 넘기기 + 두 손가락 넘기기 + PageControl 사용) (0) | 2020.08.27 |
---|---|
IOS) Pin Gesture_02 (이미지 확대) (0) | 2020.08.27 |
IOS ) SwipeGuesture(스와이프 제스쳐) (0) | 2020.08.27 |
IOS) GPS 위치 (사진필요) (0) | 2020.08.27 |
IOS) 웹사이트 연결 (0) | 2020.08.26 |