How do you implement a pixelate transition like this (animated gif) in iOS?
Is it possible to implement with Core Animation?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
C4 – Travis’ comment being correct, your best option is probably to render the animation live yourself. You’ll want to take the code in QA1703 for screen capture, but adjust the size of the context you create at
UIGraphicsBeginImageContextWithOptionsand alter the Core Graphics current transform matrix (CTM) appropriately immediately after the call toUIGraphicsGetCurrentContext. So, just typing as I write this, your adjustments would be to result in something like:With scale = 1.0, you’ll get back a
UIImageexactly equal to the screen. With scale = 0.5 you’ll get one with half as many pixels across and down, with scale = 0.25 you’ll get a quarter as many pixels across and down, etc.You can then put that
UIImageinto aUIImageView, and set its layer’s magnification filter tokCAFilterNearest. Showing that image view should give you a deliberatedly pixellated version of the original. You can then either be lazy and just keep performing a half-size render of what’s already on screen (so the live view the first time, the image view subsequently) or adapt the code not to render from the main window but rather from a nominated view and re-render from the original view hierarchy as required (which would work if you wanted to do something other than keep dividing the scale by an integer).