Hello.
I want to change the UIView value for other classes (for example, someView.alpha value) when I press the button, but it doesn't change.
Regarding the code below, it seems that each case was reached when I pressed the button (I checked with print), but the value of the properties of the desired view remains the same.
By the way, it seems to change in the initial state (ViewDidLoad).
Please tell me how to change the value when you press the button.
ViewController.swift
class ViewController:UIViewController {
@IBOutlet weak var vHome:UICollectionView!
@IBOutlet weak var vSearch:UICollectionView!
override func viewDidLoad(){
super.viewDidLoad()
SelectRd(rd:3)// It seems that the initial value of ViewDidLoad can be changed.
}
}
extensionViewController {
func selectRd(rd reader:Int){
variableView—UIView!
let animateVHome=vHome
let animateVSearch=vSearch
UIView.animate(withDuration: 0.3, delay: 0.0, animations: {
animateVHome.alpha = 0.0
animateVSearch.alpha = 0.0
}, completion : nil )
switchreader {
case2:
animateView= animateVHome
case3:
animateView= animateVSearch
default:
break
}
UIView.animate(withDuration: 0.3, delay: 0.3, animations: {
animateView.alpha=1.0
}, completion : nil )
}
}
Another.swift
class Another {
@objc func buttonTapped (sender: HeaderButton) {
let vC = ViewController
vC.selectRd(rd:2)// This button does not change when pressed.I'm going to the case.
}
}
Why don't you increase the delay of the last UIView.animate a little?
New animations may be ignored when the animation time is up.
UIView.animate(withDuration: 0.3, delay: 0.4, animations: {
animateView.alpha=1.0
}, completion : nil )
© 2024 OneMinuteCode. All rights reserved.