# Strange Transform of UIButton

**URL:** <https://ifnotnil.com/t/strange-transform-of-uibutton/2012>\
**Category:** Other\
**Created:** [2 September 2021 19:39 UTC](https://ifnotnil.com/t/strange-transform-of-uibutton/2012 "2021-09-02T19:39:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [2 September 2021 19:39 UTC](https://ifnotnil.com/t/strange-transform-of-uibutton/2012/1 "2021-09-02T19:39:43Z")

</div>

I’m attempting to create an animation where it appears as if a UIButton is flipping horizontally

This SHOULD be the code

```auto
public func animateFLIP( _ newValue:Bool) {
if zFaceDown != newValue {
	UIView.animate(withDuration: speed_CARDFLIP , delay: 0.0, options: .curveLinear, animations: {
				self.transform = CGAffineTransform(scaleX: 0.01, y: 1);
	},completion: { _ in
		self.isFaceDown = newValue
		UIView.animate(withDuration: speed_CARDFLIP , delay: 0.0, options: .curveLinear, animations: {
					self.transform = CGAffineTransform(scaleX: 1, y: 1);
				})
			})
		}
	}

```

but the first transform makes the UIButton wider than the whole screen (when in fact it should go to 1% of its starting width  
The 2nd transform is suppose to return it to normal… but in fact returns it to about 2x its original size

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [2 September 2021 20:13 UTC](https://ifnotnil.com/t/strange-transform-of-uibutton/2012/2 "2021-09-02T20:13:01Z")

</div>

have you tried the seemingly silly transform set as

```auto
CGAffineTransform(scaleX: 100, y: 1);

```

JUST for shits & giggles as the code you posted _seems_ right  
but gives the opposite of what you’d expect  
which is the only reason I’d suggest trying the opposite

docs definitely seem to say what youre doing should be right

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [2 September 2021 20:22 UTC](https://ifnotnil.com/t/strange-transform-of-uibutton/2012/3 "2021-09-02T20:22:24Z")

</div>

actually what you suggested … **seems** to be true… but even so, the transform to 1,1 still comes out wrong…

Apple Docs… gotta love em! (well actually no, you don’t)

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [2 September 2021 21:15 UTC](https://ifnotnil.com/t/strange-transform-of-uibutton/2012/4 "2021-09-02T21:15:17Z")

</div>

🤷‍♂️

i had to read the page a couple times to think oh maybe they are scaling from the left hand into the right which would explain why the .01 makes things larger

but given the math they claim it makes no sense

the new X, Y should be the old X Y multiplied by (.01 and 1)
