Animation and object properties

  1. 5 years ago

    henry_cho

    30 Apr 2018 User since 2018

    Hi @marco ,
    Hope the new release is going well. I have two questions.
    1. Is it possible to directly set position .x ,position.y or width or height of an object outside of an animation.
    For example to create a progress bar?
    2. Can you use a variable in the animation controller. Eg to set scale.x to scale.x * progress
    Also when I run an animation it seems to complete and then return to the start state. Is there a way to have it stop on the last frame?
    Thanks for your help

  2. marco

    30 Apr 2018 Administrator User since 2016

    Hi @henry_cho,
    1. Every control inherits from UIView so it automatically has the frame property. You can use it to change its size and/or position. For example:

    MyControl.frame.size.width = 200;
    MyControl.frame.size.height = 20;
    MyControl.frame.origin.x = 10;
    MyControl.frame.origin.y = 50;

    More at http://docs.creolabs.com/classes/UIView.html

    2. To have more control over an animation it is better to use the animate method. I attached a sample project to this post.

  3. henry_cho

    10 May 2018 User since 2018

    Thanks Marco, that really helped. Any update on the next version of the beta?
    In terms of the method:
    func animate(duration: Float, delay: Float, options: Int, closure: Closure, completion: Closure) Animate changes to one or more views using the specified duration, delay, options and completion handler
    I understand duration, delay and I think completion and closure.
    What are valid options?

  4. marco

    10 May 2018 Administrator User since 2016

    Hi @henry_cho beta is ready, we are waiting for Apple to approve the Player before releasing it.
    options are the same as Apple https://developer.apple.com/documentation/uikit/uiviewanimationoptions?language=objc

    In the upcoming beta we exposed the correct enum.

  5. henry_cho

    12 May 2018 User since 2018

    Thank Marco, would you mind updating your earlier example to include one of those options. I'm a bit unclear of the syntax.
    Thank you

  6. marco

    12 May 2018 Administrator User since 2016

    Sure @henry_cho attached to this message you can find an updated Animation example with options.

  7. henry_cho

    13 May 2018 User since 2018

    @marco thank that's very helpful

or Sign Up to reply!