ios - What animation does Frontback app use for their camera after you press the camera button? -
we trying create animation after press camera button similar frontback app (frontback.me) , haven't been able find cocoa pod or right terminology animation. animation similar old iris shutter animation apple used use.
after press camera button, there animation. animation circle overlaying image captured. inside circle image captured , outside black. circle gets smaller , smaller until reaches center , entire image captured shown.
please advise on can find animation, custom create and/or correct terminology specific animation. thank you!
is animation looking for, quite new xcode: cashapelayer path animation -- shrinking circle
thanks again!
i'm frontback co-founder , developer made this. how did it, it's in rubymotion can ported obj-c (or easier swift), idea.
def setupcaptureanimation w = view.bounds.size.width h = view.bounds.size.height location = cgpointmake(w/2, h/2) shapelayer = cashapelayer.layer outerradius = 0.5 * math.sqrt(w**2 + h**2) # circle around view bounds @animstartpath = makecircleatlocation(location, radius:outerradius).cgpath @animendpath = makecircleatlocation(location, radius:0).cgpath shapelayer.path = @animstartpath shapelayer.fillcolor = uicolor.blackcolor.cgcolor @animlayer = shapelayer end def playcapturestartanimation view.layer.addsublayer(@animlayer) pathanimation = cabasicanimation.animationwithkeypath("path") pathanimation.setvalue("start", forkey:"id") pathanimation.duration = 0.1 pathanimation.fromvalue = @animstartpath pathanimation.tovalue = @animendpath pathanimation.delegate = self @animlayer.addanimation(pathanimation, forkey:nil) @animlayer.path = @animendpath end def playcaptureendanimation pathanimation = cabasicanimation.animationwithkeypath("path") pathanimation.setvalue("end", forkey:"id") pathanimation.duration = 0.2 pathanimation.fromvalue = @animendpath pathanimation.tovalue = @animstartpath pathanimation.delegate = self @animlayer.addanimation(pathanimation, forkey:nil) @animlayer.path = @animstartpath end def makecircleatlocation(location, radius:radius) path = uibezierpath.bezierpath # fill rectangle rect = view.bounds path.movetopoint(cgpointmake(cgrectgetminx(rect), cgrectgetminy(rect))) path.addlinetopoint(cgpointmake(cgrectgetminx(rect), cgrectgetmaxy(rect))) path.addlinetopoint(cgpointmake(cgrectgetmaxx(rect), cgrectgetmaxy(rect))) path.addlinetopoint(cgpointmake(cgrectgetmaxx(rect), cgrectgetminy(rect))) path.addlinetopoint(cgpointmake(cgrectgetminx(rect), cgrectgetminy(rect))) # remove circle path.addarcwithcenter(location, radius:radius, startangle:0.0, endangle:2 * math::pi, clockwise:true) path.closepath path end def animationdidstop(anim, finished:finished) if anim.valueforkey("id") == "start" # trigger capture , after playcaptureendanimation else @animlayer.removefromsuperlayer # done end end the drawing trick resides in makecircleatlocation:radius:: when draw path, if superimpose (like circle) on top of else (like rectangle), intersection removed path. drawing circle in rectangle, circle removed rectangle.
you first have call setupcaptureanimation @ initialization. when user taps camera button have call playcapturestartanimation play shrinking animation, delegate method animationdidstop:finished called. @ moment screen black, have capture image camera session. when it's taken, call playcaptureendanimation , play reverse animation.
Comments
Post a Comment