Apologies
You must be signed in to watch this lesson.
Cell Abs Coordinates and Fullscreen Animation
AppStore JSON APIs
Each cell that can be expanded fullscreen should be clickable and animate to fill the entire screen. The quickest way to accomplishing this is to use frames and animate them from a starting location to an ending location. To do so, we'll first have to figure out the origin of our cell frames during didSelectItemAt. This can be tricky but its just a simple one line of code that can be found on StackOverflow. Enjoy.

Comments (7)
tonystarkli
5 years ago
Hi Brian, Why Don't you use transition delegate here? What is the benefit of your way?
Brian Voong
5 years ago
tonystarkli
5 years ago
Thank you so much!
juliolocoh
4 years ago
hi Brian when you hide the Today's navigationBar the title disappears how to have the title appeared like the appStore
romesh
4 years ago
I am interested too...
tsangaris
4 years ago
Hey Brian, Absolutely brilliant tutorial so far! I dont think that its just me: Animations are much more easier than we all think they are! And this is thanks to your guidance! Just a question: Since we are going to require the "startingFrame" when removing the redView, why not pass it as a parameter in the handleRemoveRedView() method? What is the benefit of declaring it as a local variable? Thank you so much!
Maciek Górecki
4 years ago
I don't think you can pass any extra parameters in a selector? Correct me if I'm wrong.
dog
4 years ago
This topic is #1 reason I purchased this course
applebyte
4 years ago
SAME!!! and he delivered flawlessly
Jorge Casariego
4 years ago
Same here!!
Chad-michael Muirhead
4 years ago
Same!!
Kritbovorn Taweeyossak
4 years ago
Same sir.
Chad-michael Muirhead
4 years ago
i added the gesture recognizer to my view but it isnt being called i even checked by adding a print statement in the function. can anyone help , i even tried adding the delegate and all that but still not being called ``` func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let fullScreen = UIView() fullScreen.isUserInteractionEnabled = true fullScreen.backgroundColor = .red let tapGesture = UIGestureRecognizer(target: self, action: #selector(handleTap(gesture:))) tapGesture.delegate = self fullScreen.addGestureRecognizer(tapGesture) view.addSubview(fullScreen) guard let cell = collectionView.cellForItem(at: indexPath) else {return} guard let startingFrame = cell.superview?.convert(cell.frame, to: nil) else{return} fullScreen.frame = startingFrame UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.7, options: .curveEaseOut, animations: { fullScreen.frame = self.view.frame }) { (done) in } } @objc func handleTap(gesture: UITapGestureRecognizer){ print("tapped") gesture.view?.removeFromSuperview() } ```
bermillo.mrk
4 years ago
Hi Chad-michael Muirhead, It's a little bit late but, I think you need to change: let tapGesture = UIGestureRecognizer(target: self, action: #selector(handleTap(gesture:))) to: let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(gesture:))) instead.
matlyles
4 years ago
Came for this specific feature, got so much more.. fantastic project
frankusu
3 years ago
Hey Brian, We add the redView when we click on the cell What is the difference between collectionView.addSubview(redView) vs view.addSubview(redView) ? I still don't understand when to use view vs collectionView when in a UICollectionViewController could you explain, thank you!
HELP & SUPPORT