gpt4 book ai didi

ios - 在 View Controller 之间滑动手势

转载 作者:可可西里 更新时间:2023-11-01 06:21:40 24 4
gpt4 key购买 nike

我正在尝试在背景上创建滑动。我有三种不同颜色的背景。我做了一个按钮,当我点击我的按钮时,我的背景变成了下一个场景。我想改变这个,我想向左或向右滑动我的拇指来改变背景,而不必点击按钮。我将如何实现。

这里有更多的细节

我的 View Controller 是

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}

enter image description here

最佳答案

快速版本:

添加手势识别器:

override func viewDidLoad() {
super.viewDidLoad()
let recognizer: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "swipeLeft:")
recognizer.direction = .Left
self.view .addGestureRecognizer(recognizer)
}

Action 函数:

func swipeLeft(recognizer : UISwipeGestureRecognizer) {
self.performSegueWithIdentifier("MySegue", sender: self)
}

关于ios - 在 View Controller 之间滑动手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26478383/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com