Dynamic button with Lottie - ios

I want to create button with three different states namely Initial, Loading, Completed.
UI for button state:
Initial -> TextLabel
Loading -> Loading indicator/multiple images
Completed -> TextLabel
It will be in Initial state normally when user clicks it then It will change its state to Loading with transforming itself to show loading indicator inside it. Once completed it will animate and transform to show the label.
How can I achieve it with Lottie?
I need to set initial and completed state texts dynamically but as per the docs I couldn't find out a way to change text into Lottie.
With Lottie I can use progress animation to handle different states of button but how can I change texts programatically without new json file.
Lottie doesn't support text layer in iOS. Any workaround for that except using shape layer?

You can modify the text for the Button in the JSON, via directly modifying the JSON itself programmatically. As Lottie animation and views are governed by JSON, it's not possible.

There's no proper API support in Lottie for this, but this thread has a discussion on possible ways you can change the text via the json file:
https://github.com/airbnb/lottie-web/issues/238

Related

Custom Keyboard Accessory view input

I have created a custom accessory view to supplement the standard Apple alpha iOS keyboard.
The purpose is to add a line of numeric keys to prevent flipping back and forth between keyboard views. At first, I created a toolbar and loaded it with a set of 0 - 9 titled buttonItems and it functioned quite well. However, it looked terrible, not at all like the alpha keys despite adding a rounded rect background image to each key because the system apparently prevents customizing font size and button spacing inside the stack view of the toolbar. Therefore, I created a UIView xib and loaded it with a stackView full of customized numerical buttons. When I add the UIView as the accessory view it looks pretty darn close to the rest of the Apple Alpha keyboard. The issue now is that the touch-up events go to the UIView class of the accessory view. Is there a clever, efficient way to have the button presses in the accessory emulate the std keyboard feeding into TextField: shouldChangeCharactersIn? I could package the button presses into a local notification event to get it into the class holding the textField but that seems terribly inelegant! Any suggestions would be greatly appreciated. Stay Safe!
Not the best answer, but I did implement notification on key button press with an observer in the main view class. The observer does a TextField.insertText which is suboptimal since I will need to refactor the several hundred lines of code that performs real-time language translation in the shouldChangeCharacters methods. Ah well.

Create a custom step indicator in iOS with Swift

How do I create a progress indicator as shown in swift for iOS? Tried various libraries. But nothing fits exactly.The color should be in gradient and the current state must show the step number.
If you want to create any custom control element You should inherits your class from UIControl. You can read about this here:
custom knob,
custom slider.
But You will have to write too many lines of code to create customize view.
However, You can use my turnkey solutions: https://github.com/vladislovshilov/StepView
Unfortunately this library does not support touch yet.
Here is an example that uses a UIStackView, works nicely with auto layout, is animatable, and is configurable in Interface Builder.
https://gist.github.com/Dev1an/aa54ae331f4065569dc613d7f904bd54

Xcode Display a loading view until the second view loads (on a segue show)

I have an app that switch views using a segue when a button is clicked.
The second view loads data from the internet and it can take a couple of seconds.
I would like to know how can i display a loading view/splash screen in the meantime so the view could finish the loading and the app wont appear like it's doing nothing.
Thanks!
Check this library SwiftSpinner. It serves the purpose of your needs. It's really brilliant.
Call the necessary function from the library in the viewDidLoad method of your ViewController which loads the data from the internet. Remove this view in DidFinishLoading method of the NSURLProtocol (It's an optional func declared in that class which detects when the request to that URL is complete). The documentation is given in that library itself.
Sounds like you're looking for an activity indicator. I've used the custom class posted https://stackoverflow.com/a/32661590/3516923 with success. Just a note of warning, in his class he blocks all input while the indicator is in view. If you want to make it so your users can back out before things finish you need to remove UIApplication.sharedApplication().beginIgnoringInteractionEvents() and UIApplication.sharedApplication().endIgnoringInteractionEvents() from the start and stop animating functions.
If what you want is really a splash screen, have a UIImageView underneath the view that you're loading. Set the image to your splash screen image. Set the loading view to hidden=YES before it's shown, then set hidden to NO after it finishes loading. You could even set the opacity of the frontmost view to give you a fading effect.
1.You need to find a kind of indicator, suck like an activity indicator or something else to show the loading UI to the user.
2.Set the user interaction unable, so that the user won`t touchup inside repeatedly.
3.Start the indicator, set the user interaction unable when you load the server data, and stop the indicator animation when you finish, hide the indicator, enabled the user interaction.

iOS Format Background

I am creating a simple quote app as a learning experience and need to format it to look better.
I am trying to make the background have a "white square" where the text is and make the text black. Just like the Twitter app has when you click on a tweet.
What is the best way to do this and what should I start with?
I know it is very simple, I'm only 15 and am trying to learn iOS. As you can see I have a server and have the app up and running, just want to format before I call it complete. Thanks! :)
-Henry
This will depend on how you created the label that displays your text, but you can do this very easily:
If you created your UI in a Storyboard / XIB file in XCode: assuming you dragged out a UILabel or UITextView, you can use the Attributes Inspector to set the text color and the background color (in the View section) of the element holding the text.
If you created the label (or text view) in code, you can set the textColor property and the backgroundColor properties programmatically.

drag text between textfield like mail app of ios 5

I want implement drag text between textfield like mail app of ios5.
here is video link and image what i want to implement.
video link.
(just observe on 2:49 min).
http://www.youtube.com/watch?v=-JURDFe2PNE&feature=b-vrec
image:
Split this into three tasks:
Containing the data you want into an appropriate UIView-based class/subclass
Handling the relevant touch events to initiate and end the drag and drop
Animating the move between your source and destination
You can implement these one at a time in order to develop precisely the drag and drop functionality you need.
You shouldn't need to convert your view to an image, as UIView subclasses can be animated by Core Animation. This SO post has more info on handling touch events.
Good luck!

Resources