나는 솔직한 해결책을 제시 할 것입니다.
먼저,이 순간에 보여주는있는 일을 나타내는 열거 만들 : 당신,에게 실제로
var currentMode = CountDownMode.Days
을 그리고 그런 다음
enum CountDownMode {
case Days, Minutes, Hours, Seconds
}
를 컨트롤러에이 같은 변수를 선언 이러한 간단한 접촉을 인식하기 위해 제스처 인식기를 사용할 필요가 없습니다. 그냥 touchesBegan
를 오버라이드 (override) :
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
}
touchesBegan
에서 currentMode
의 값을 사용하여, 당신은 쉽게 옆에 어떤 모드 파악하고 그에 따라 텍스트를 변경할 수 있습니다
switch currentMode {
case .Days:
// change text here
currentMode = .Minutes
case .Minutes:
// change text here
currentMode = .Hours
case .Hours:
// change text here
currentMode = .Seconds
case .Seconds:
// change text here
currentMode = .Days
}
그것은 라벨 수 있습니다. – Alex
큰 문제가 아니라 레이블 위에 버튼을 놓고 'label.center = button.center, label.width = button.width, label height = button.height'와 같은 자동 레이아웃으로 맞 춥니 다. – Traveler