HomeiOS DevelopmentLearn how to make iOS swift block animation inside Customized UIView perpetual?

Learn how to make iOS swift block animation inside Customized UIView perpetual?


Present Code

At the moment I’ve the next code for AnimationView.swift

import Basis
import UIKit

class AnimationView: UIView {

    personal let backgroundView = UIView()
    personal let foregroundView = UIView()

    override init(body: CGRect) {
        tremendous.init(body: body)
...

And in addition I’ve the next code for ViewController.swift

import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any extra setup after loading the view.
    }

    override func viewDidAppear(_ animated: Bool) {
        let x = AnimationView(body: .zero)
...

Drawback

The block animation code has points associated to the view controller’s life cycle and whether or not or not it was added to the view hierarchy earlier than calling UIView.animate(...). Ideally, I need the animation to only run repeatedly on a loop with none interruptions or issues about these elements. Anybody have any options?

UIView.animate(withDuration: 2.0, delay: 0, choices: [.autoreverse, .repeat], animations: {
    self.foregroundView.remodel = CGAffineTransform(scaleX: 0.3, y: 0.3)
}, completion: nil)

Screenshots

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments