How do I check if a particular UIView's transform is either was set via CGAffineTransformIdentity or was moved physically?
Scenario:
I can position UIView via either changing its frame or via transformation. Once the UIView has been positioned either via transform or change of frame... I wish to revert it back to its original layout via a different button.
Observation:
1) If I had changed the UIView's frame, I can revert it back via original frame values.
2) If I had transformed the UIView, I can revert it back via the CGAffineTransformIdentity.
So...How would I know the difference, programmatically?
I'm assuming by testing the transform. How exactly?
P.S. This purely for edification.
var transform = CGAffineTransformIdentity
if origFrame != containerView.frame {
// TODO: Need to determine if reset transform CGAffineTransformIdentity vs moving containerView.
print("1b) Reset Layout")
} else {
print("1a) Animate Transform.")
transform = CGAffineTransformScale(transform, 0.25, 0.25)
transform = CGAffineTransformTranslate(transform, -400, -600)
}
UIView.animateWithDuration(1.0, animations: {
self.containerView.transform = transform
})