A new UIView is displayed over the old one. While the UIViewController is presenting I want the background to be default. But as soon as it finishes presenting the UIView I want the background to turn lightGrey and the alpha should change from 0 to 0.6.
I know how to change the background and the alpha for my View, but how can I do these changes from the moment the UIViewController finished displaying?
Presenting UIViewController:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let user = indexPath.row
OperationQueue.main.addOperation {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier :"ShowProfileView") as! showProfileViewController
viewController.username = self.usernameList[user]
self.present(viewController, animated: true)
}
}
UIViewController:
class showProfileViewController: UIViewController {
@IBOutlet weak var ViewController: UIView!
@IBOutlet weak var profileLabel: UILabelX!
var username = String()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
profileLabel.text = username
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
ViewController.layer.cornerRadius = 20
ViewController.layer.masksToBounds = true
}
/*func updateProfileView() {
view.backgroundColor = UIColor.lightGray.withAlphaComponent(0.6)
view.isOpaque = false
}*/
}