iOS Animations by Tutorials by 2018
Author:2018
Language: eng
Format: epub
Publisher: Ray Wenderlich
MicMonitor: Monitors the input levels on your iPhone’s microphone and repeatedly calls a closure expression that you provide. This is where you have the chance to update the display.
Everything is ready for you to jump in and add some cool animations!
Setting up the replicator layer
Open ViewController.swift and add the following two properties:
let replicator = CAReplicatorLayer() let dot = CALayer()
dot will be a simple shape drawn using the CALayer basic properties such as background and border color. replicator will help you get multiple dot copies on screen.
Next, add the following constants you’ll need to create your animation:
let dotLength: CGFloat = 6.0 let dotOffset: CGFloat = 8.0
You’ll use the first constant as the width and height of the dot layer, while the second constant holds the offset between each dot replication.
To finish off the setup, you’ll have to add the replicator layer to the view controller’s view. Add the following to viewDidLoad():
replicator.frame = view.bounds view.layer.addSublayer(replicator)
Here, you make the replicator layer the same size as the view controller’s view and add it as a sub-layer. If you were to run the project at this point, nothing would appear to have changed; that’s because you didn’t add any visible content to replicate.
The next step is to dress up the dot layer and add it to replicator in order to display the replications. Append the following to viewDidLoad():
dot.frame = CGRect( x: replicator.frame.size.width - dotLength, y: replicator.position.y, width: dotLength, height: dotLength) dot.backgroundColor = UIColor.lightGray.cgColor dot.borderColor = UIColor(white: 1.0, alpha: 1.0).cgColor dot.borderWidth = 0.5 dot.cornerRadius = 1.5
You first position the dot layer towards the right edge of the replicator and therefore, the right edge of the screen. Then you set the layer’s background color and add a border. At this point the layer will look like the following:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9915)
The Mikado Method by Ola Ellnestam Daniel Brolund(9778)
Dependency Injection in .NET by Mark Seemann(9339)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7778)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Svelte with Test-Driven Development by Daniel Irvine(7159)
Test-Driven Development with PHP 8 by Rainier Sarabia(6886)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6756)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6532)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Web Development with Django by Ben Shaw Saurabh Badhwar(6219)
React Application Architecture for Production by Alan Alickovic(5945)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5806)
Kotlin in Action by Dmitry Jemerov(5063)
Audition by Ryu Murakami(4583)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4452)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4317)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4298)
Functional Programming in JavaScript by Mantyla Dan(4038)
