почему не работает UIView.animate(withDuration: 0.4, delay: 0, options: [.allowUserInteraction], animations: { }
обшаркал инет,но так и не нашел четкого ответа с примером почему не работает в Swift 5.2 UIView.animate(withDuration: 0.4, delay: 0, options: [.allowUserInteraction], animations: {}... именно опция .allowUserInteraction...остальные вроде срабатывают...пробовал по разному, но никак...у кого работает - отпишитесь...
import UIKit
class ViewController: UIViewController, UIGestureRecognizerDelegate {
var plate_1_left: UIImageView!
var timer_plate_start: Timer!
var timer_plate_repeat: Timer!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
sleep(3)
self.timer_plate_start = Timer.scheduledTimer(timeInterval: 1, target:
self, selector:
#selector(start_plate),userInfo:nil,repeats: false)
self.timer_plate_repeat = Timer.scheduledTimer(timeInterval: 5, target:
self, selector:
#selector(start_plate),userInfo:nil,repeats: true)
self.view.backgroundColor = UIColor(patternImage: UIImage(named:
"bks0003b.jpg")!)
} // func viewDidLoad()
@objc func start_plate(){
let placeX_plate = self.view.frame.midX + 300
let placeY_plate = self.view.frame.midY - 400.0
print("plate = 0");
self.plate_1_left = UIImageView(frame:CGRect(x: placeX_plate, y:
placeY_plate, width:
50, height: 50))
self.plate_1_left.image = UIImage(named: "tarelka0001.png")
self.view.addSubview(self.plate_1_left)
UIView.animate(withDuration: 8.0, delay: 0.2, options:
[.allowUserInteraction],
animations:
{
self.plate_1_left.frame = CGRect(x: 20, y: 500, width: 150, height:
100)
}, completion: nil)//{ animationFinished in
AnimeView.removeFromSuperview()
// tap plate
let tap_plate: UIImageView! = self.plate_1_left
let tap_plate_1_left: UITapGestureRecognizer! =
UITapGestureRecognizer(target: self,
action: #selector(ViewController.tap_plate_1))
tap_plate_1_left.delegate = self
tap_plate_1_left.numberOfTapsRequired = 2
//doubleTapGestureRecognizer.numberOfTouchesRequired = 2
tap_plate.addGestureRecognizer(tap_plate_1_left) // без этого тап не
tap_plate_1_left.isEnabled = true
self.view!.addSubview(tap_plate)
tap_plate.isUserInteractionEnabled = true // ==???
// ***** tapGesture_finish plate_1_left
} // func start_plate()
@objc func tap_plate_1() {
print("tap_plate_1");
} // func tap_plate_1()
} // class