From 4038d3a7c312584624f54c0affcc26c7cc216b22 Mon Sep 17 00:00:00 2001 From: brandon_withrow Date: Mon, 28 Aug 2017 14:57:31 -0700 Subject: [PATCH] Updated example --- Example/Tests/Switch_States.json | 1 + Example/lottie-ios.xcodeproj/project.pbxproj | 4 +++ Example/lottie-ios/LAControlsViewController.m | 32 +++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Example/Tests/Switch_States.json diff --git a/Example/Tests/Switch_States.json b/Example/Tests/Switch_States.json new file mode 100644 index 0000000000..e03fe07816 --- /dev/null +++ b/Example/Tests/Switch_States.json @@ -0,0 +1 @@ +{"v":"4.7.0","fr":60,"ip":0,"op":21,"w":100,"h":100,"nm":"LottieSwitch","ddd":0,"assets":[{"id":"comp_7","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"X Outlines","parent":3,"ks":{"o":{"a":0,"k":100},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[-90]},{"t":20}]},"p":{"a":0,"k":[15.346,24.665,0]},"a":{"a":0,"k":[11.313,11.759,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7.391,7.84],[-7.493,-7.049]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0,0.6509804,0.6,1],"e":[0.7568628,0.7568628,0.7568628,1]},{"t":7}]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":1,"ml":10,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[11.364,11.364],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[0]},{"t":15}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[100]},{"t":15}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Checkmark Outlines","parent":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[10.359,11.571,0]},"a":{"a":0,"k":[17,13,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[12,-8],[-4.001,8],[-12,0]],"c":false}],"e":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[9.332,-8],[-6.669,8],[-14.668,0]],"c":false}]},{"t":20}]},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[3.4]},{"t":20}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[100],"e":[65.2]},{"t":20}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0,0.6509804,0.6,1],"e":[0.7568628,0.7568628,0.7568628,1]},{"t":7}]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[17,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"White BG Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[70.347,49.429,0],"e":[49.428,49.429,0],"to":[0,0,0],"ti":[0,0,0]},{"t":20}]},"a":{"a":0,"k":[24.25,24.25,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-17.673,0],[0,17.673],[17.673,0],[0,-17.673]],"o":[[17.673,0],[0,-17.673],[-17.673,0],[0,17.673]],"v":[[8.544,32.018],[40.544,0.018],[8.544,-31.982],[-23.456,0.018]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"a":0,"k":[1,1,1,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[7.125,24.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[93,93],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"Switch Outline Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[58.858,49.696,0]},"a":{"a":0,"k":[42,34,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,17.677],[-17.652,0],[0,0],[0,-17.677],[17.652,0],[0,0]],"o":[[0,-17.673],[0,0],[17.671,0],[0,17.673],[0,0],[-17.671,0]],"v":[[-50.46,-0.154],[-18.463,-32.154],[1.544,-32.154],[33.54,-0.154],[1.544,31.846],[-18.463,31.846]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tr","p":{"a":0,"k":[42,34],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":1,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0,0.6509804,0.6,1],"e":[0.7568628,0.7568628,0.7568628,1]},{"t":9}]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1}]},{"id":"comp_8","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"X Outlines","parent":3,"ks":{"o":{"a":0,"k":100},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[-90]},{"t":20}]},"p":{"a":0,"k":[15.346,24.665,0]},"a":{"a":0,"k":[11.313,11.759,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7.391,7.84],[-7.493,-7.049]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","c":{"a":0,"k":[1,1,1,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":1,"ml":10,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[11.364,11.364],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[0]},{"t":15}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[100]},{"t":15}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Checkmark Outlines","parent":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[10.359,11.571,0]},"a":{"a":0,"k":[17,13,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[12,-8],[-4.001,8],[-12,0]],"c":false}],"e":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[9.332,-8],[-6.669,8],[-14.668,0]],"c":false}]},{"t":20}]},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[3.4]},{"t":20}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[100],"e":[65.2]},{"t":20}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":0,"k":[1,1,1,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[17,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"White BG Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[70.347,49.429,0],"e":[49.428,49.429,0],"to":[0,0,0],"ti":[0,0,0]},{"t":20}]},"a":{"a":0,"k":[24.25,24.25,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-17.673,0],[0,17.673],[17.673,0],[0,-17.673]],"o":[[17.673,0],[0,-17.673],[-17.673,0],[0,17.673]],"v":[[8.544,32.018],[40.544,0.018],[8.544,-31.982],[-23.456,0.018]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"a":0,"k":[0,0.6509804,0.6,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[7.125,24.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[93,93],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"Switch Outline Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[58.858,49.696,0]},"a":{"a":0,"k":[42,34,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,17.677],[-17.652,0],[0,0],[0,-17.677],[17.652,0],[0,0]],"o":[[0,-17.673],[0,0],[17.671,0],[0,17.673],[0,0],[-17.671,0]],"v":[[-50.46,-0.154],[-18.463,-32.154],[1.544,-32.154],[33.54,-0.154],[1.544,31.846],[-18.463,31.846]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tr","p":{"a":0,"k":[42,34],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":1,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"fl","c":{"a":0,"k":[1,1,1,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1}]},{"id":"comp_9","layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Switch 2","refId":"comp_10","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":21,"st":0,"bm":0,"sr":1}]},{"id":"comp_10","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"X Outlines","parent":3,"ks":{"o":{"a":0,"k":100},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[-90]},{"t":20}]},"p":{"a":0,"k":[15.346,24.665,0]},"a":{"a":0,"k":[11.313,11.759,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7.391,7.84],[-7.493,-7.049]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","c":{"a":0,"k":[0.7568628,0.7568628,0.7568628,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":1,"ml":10,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[11.364,11.364],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[0]},{"t":15}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":3,"s":[50],"e":[100]},{"t":15}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Checkmark Outlines","parent":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[10.359,11.571,0]},"a":{"a":0,"k":[17,13,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[12,-8],[-4.001,8],[-12,0]],"c":false}],"e":[{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[9.332,-8],[-6.669,8],[-14.668,0]],"c":false}]},{"t":20}]},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[0],"e":[3.4]},{"t":20}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.52],"y":[0]},"n":["0_1_0p52_0"],"t":0,"s":[100],"e":[65.2]},{"t":20}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":0,"k":[0.7568628,0.7568628,0.7568628,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":2},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[17,13],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"White BG Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.52,"y":0},"n":"0_1_0p52_0","t":0,"s":[70.347,49.429,0],"e":[49.428,49.429,0],"to":[0,0,0],"ti":[0,0,0]},{"t":20}]},"a":{"a":0,"k":[24.25,24.25,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-17.673,0],[0,17.673],[17.673,0],[0,-17.673]],"o":[[17.673,0],[0,-17.673],[-17.673,0],[0,17.673]],"v":[[8.544,32.018],[40.544,0.018],[8.544,-31.982],[-23.456,0.018]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","c":{"a":0,"k":[0.5737745,0.5734493,0.5734493,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[7.125,24.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[93,93],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"Switch Outline Outlines","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[58.858,49.696,0]},"a":{"a":0,"k":[42,34,0]},"s":{"a":0,"k":[99.867,99.925,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,17.677],[-17.652,0],[0,0],[0,-17.677],[17.652,0],[0,0]],"o":[[0,-17.673],[0,0],[17.671,0],[0,17.673],[0,0],[-17.671,0]],"v":[[-50.46,-0.154],[-18.463,-32.154],[1.544,-32.154],[33.54,-0.154],[1.544,31.846],[-18.463,31.846]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"tr","p":{"a":0,"k":[42,34],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":1,"cix":2,"ix":1,"mn":"ADBE Vector Group"},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0.6509804,0,0.1116479,1],"e":[0.6403493,0.463802,0.463802,1]},{"t":9}]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"}],"ip":0,"op":21,"st":-15,"bm":0,"sr":1}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Button","refId":"comp_7","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[50,49,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":21,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":0,"nm":"Selected","refId":"comp_8","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":21,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":0,"nm":"Disabled","refId":"comp_9","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":21,"st":0,"bm":0,"sr":1}]} \ No newline at end of file diff --git a/Example/lottie-ios.xcodeproj/project.pbxproj b/Example/lottie-ios.xcodeproj/project.pbxproj index 028fc2446c..4bb61ca1d5 100644 --- a/Example/lottie-ios.xcodeproj/project.pbxproj +++ b/Example/lottie-ios.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ 622F770B1F2BE63100269858 /* Z.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76ED1F2BE63100269858 /* Z.json */; }; 629EC57F1F54BFF1005B2C59 /* LAControlsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */; }; 629EC5811F54C00B005B2C59 /* Switch.json in Resources */ = {isa = PBXBuildFile; fileRef = 629EC5801F54C00B005B2C59 /* Switch.json */; }; + 629EC5891F54C925005B2C59 /* Switch_States.json in Resources */ = {isa = PBXBuildFile; fileRef = 629EC5881F54C925005B2C59 /* Switch_States.json */; }; 62B2546A1E3A8D310035A842 /* LottieRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254631E3A8D310035A842 /* LottieRootViewController.m */; }; 62B2546B1E3A8D310035A842 /* AnimationExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254651E3A8D310035A842 /* AnimationExplorerViewController.m */; }; 62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254671E3A8D310035A842 /* AnimationTransitionViewController.m */; }; @@ -171,6 +172,7 @@ 629EC57D1F54BFF1005B2C59 /* LAControlsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LAControlsViewController.h; sourceTree = ""; }; 629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LAControlsViewController.m; sourceTree = ""; }; 629EC5801F54C00B005B2C59 /* Switch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Switch.json; sourceTree = ""; }; + 629EC5881F54C925005B2C59 /* Switch_States.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Switch_States.json; sourceTree = ""; }; 62B254621E3A8D310035A842 /* LottieRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LottieRootViewController.h; sourceTree = ""; }; 62B254631E3A8D310035A842 /* LottieRootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LottieRootViewController.m; sourceTree = ""; }; 62B254641E3A8D310035A842 /* AnimationExplorerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationExplorerViewController.h; sourceTree = ""; }; @@ -343,6 +345,7 @@ 6003F5B6195388D20070C39A /* Supporting Files */ = { isa = PBXGroup; children = ( + 629EC5881F54C925005B2C59 /* Switch_States.json */, 622F76CF1F2BE63100269858 /* TypeFace */, 622F76B51F2BE58100269858 /* 9squares-AlBoardman.json */, 629EC5801F54C00B005B2C59 /* Switch.json */, @@ -614,6 +617,7 @@ 622F77071F2BE63100269858 /* V.json in Resources */, 622F77061F2BE63100269858 /* U.json in Resources */, 622F76CE1F2BE58100269858 /* Watermelon.json in Resources */, + 629EC5891F54C925005B2C59 /* Switch_States.json in Resources */, 622F77041F2BE63100269858 /* S.json in Resources */, 622F770A1F2BE63100269858 /* Y.json in Resources */, 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, diff --git a/Example/lottie-ios/LAControlsViewController.m b/Example/lottie-ios/LAControlsViewController.m index e9a2fac382..8e9cccbb1e 100644 --- a/Example/lottie-ios/LAControlsViewController.m +++ b/Example/lottie-ios/LAControlsViewController.m @@ -37,18 +37,44 @@ [toggle1 setProgressRangeForOffState:0 toProgress:0.5]; [toggle1 addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged]; - toggle1.center = CGPointMake(CGRectGetMidX(self.view.bounds), 90); [self.view addSubview:toggle1]; /// An animated 'like' or 'heart' button. /// Clicking toggles the Like or Heart state. /// The animation runs from 0-1, progress 0 is off, progress 1 is on LOTAnimatedSwitch *heartIcon = [LOTAnimatedSwitch switchNamed:@"TwitterHeart"]; - heartIcon.bounds = CGRectMake(0, 0, 200, 200); - heartIcon.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(toggle1.frame) + (heartIcon.bounds.size.height * 0.5)); + [heartIcon addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:heartIcon]; + /// This is a switch that also has a Disabled state animation. + /// When the switch is disabled then the disabled layer is displayed. + + LOTAnimatedSwitch *statefulSwitch = [LOTAnimatedSwitch switchNamed:@"Switch_States"]; + + /// Off animation is 0 to 1 progress. + /// On animation is 1 to 0 progress. + [statefulSwitch setProgressRangeForOnState:1 toProgress:0]; + [statefulSwitch setProgressRangeForOffState:0 toProgress:1]; + + // Specify the layer names for different states + [statefulSwitch setLayerName:@"Button" forState:UIControlStateNormal]; + [statefulSwitch setLayerName:@"Disabled" forState:UIControlStateDisabled]; + + // Changes visual appearance by switching animation layer to "Disabled" + statefulSwitch.enabled = NO; + + // Changes visual appearance by switching animation layer to "Button" + statefulSwitch.enabled = YES; + + [statefulSwitch addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged]; + [self.view addSubview:statefulSwitch]; + + // Layout + toggle1.center = CGPointMake(CGRectGetMidX(self.view.bounds), 90); + heartIcon.bounds = CGRectMake(0, 0, 200, 200); + heartIcon.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(toggle1.frame) + (heartIcon.bounds.size.height * 0.5)); + statefulSwitch.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(heartIcon.frame) + (statefulSwitch.bounds.size.height * 0.5)); } - (void)switchToggled:(LOTAnimatedSwitch *)animatedSwitch {