Sometimes you may wish you could tweak some values of your app (colors, font sizes, text) while you test it in the field. Or you would like to enable a feature to test it but don’t like to show that feature to your beta testers yet.
With my framework DDHTweaks you can do exactly this. You just need to add a bit of code to be able to change some values while the app runs. Here is an easy example. Let’s say you have a login screen and you want to animate the appearance of the textfields and the button when the screen is presented. If you have done this before, you may remember that finding the right values for the animation takes some time because you have to build and run after each change. Some people even started to tweak animations in Playgrounds because it’s faster testing on the simulator.
With DDHTweaks you can find the right values even faster.
Note: In this example I’ll use storyboards because this is the way most people build their apps. Normally I don’t use storyboards. ;)
The screen we would like to animate looks like this:
The layout of the elements is done using Auto Layout. Therefore to be able to animate thier appearance, we need references to all the layout constraints:
Each of these constraints defines the vertical distance to the next element in the layout. One way to animate the appearance of these elements could look like this:
viewWillAppear we set the constants of the constraints such that all elements are off screen. In
viewDidAppear we set the constants to the final values and tell the layout engine that we would like to animate the change. The values of the four animations are the same except for the delay. Each of the animations starts a bit later that the previous one.
Now let’s add tweaks to fine tune the animation values. To be able to use DDHTweaks, we need to add the framework to the project (for example with Carthage) and import it into the file. Then we just have to replace the assignment of the animation values with this:
We are not done yet. We need a way to show the DDHTweaks-UI. Import the DDHTweaks to AppDelegate.swift and replace the line
With this change you can bring the DDHTweaks-UI onto screen by shaking the iDevice or choosing
Hardware / Shake Gesture in the Simulator. In the demo app there are two screens with tweakable values.
When we select the login screen, we get all the values that can be changed for the animation. After some iterations we finally find out what the best values are:
After we found the perfect values for the login animation, we can export them on the main screen of the DDHTweaks-UI by sending a mail.