In this video I will take you through and teach you how easy it is to do multiple animations using CGAffineTransform. I will even explain what "Affine" means. :D
Enjoy this info? Visit my Patreon page to support educators and artists.
My YouTube Channel
Need help with SwiftUI? Check out my products at: Big Mountain Studio Website
Showing posts with label transform. Show all posts
Showing posts with label transform. Show all posts
Tuesday, February 7, 2017
Thursday, June 2, 2016
How to Scale Objects
Words
transform
- You set a UIView'stransform property to scale it. The view is transformed using mathematical formulas in an object that you supply. In this case, you are supplying a CGAffineTransformMakeScale object with two parameters.Affine
- Means to preserve parallel relationships. When you transform a view you might be scaling it (the sides of the view are still parallel to each other). You may also be rotating the view in which the sides are still parallel to each other.CGAffineTransformMakeScale
- This object will hold the values you supply and apply the correct transformation to scale the view. Takes two parameters:- Scale X (sx) - A number by which you want to scale the width.
- Scale Y (sy) - A number by which you want to scale the height.
If you provide a 1 that just means you want the width/height to be the original size.
A number lower than 1 will shrink the size of the view.
Examples
class ViewController: UIViewController {
@IBOutlet weak var greenView: UIView!
@IBAction func biggerButton(sender: AnyObject) {
// Scale the view to be twice as big.
greenView.transform = CGAffineTransformMakeScale(2, 2)
}
@IBAction func resetButton(sender: AnyObject) {
// Reset the view to be normal size.
greenView.transform = CGAffineTransformMakeScale(1, 1)
}
@IBAction func halfSizeButton(sender: AnyObject) {
// Scale the view to be half the original size.
greenView.transform = CGAffineTransformMakeScale(0.5, 0.5)
}
@IBAction func TwiceTall(sender: AnyObject) {
// Keep width 1x, make height 2x.
greenView.transform = CGAffineTransformMakeScale(1, 2)
}
@IBAction func TwiceWide(sender: AnyObject) {
// Make width 2x, make height 1x.
greenView.transform = CGAffineTransformMakeScale(2, 1)
}
@IBAction func HideButton(sender: AnyObject) {
// Scaling to zero hides the view.
greenView.transform = CGAffineTransformMakeScale(0, 0)
}
}
(Swift 2.2)
Subscribe to:
Posts (Atom)
SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...
In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...
-
This post visually shows the stack view's Alignment and Distribution property settings. There is also a section on resolving auto layou...
-
I couldn't find a tutorial on this so this is my documented journey into trying to figure out how to implement OAuthSwift into an iOS p...
-
I had someone ask about aligning text within a TextField view and I didn't have a page in my book for this but added one just now. ...