Created
May 21, 2021 08:10
-
-
Save fredriccliver/9204b6d9d229258a6e8e30a336b69a66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func commentButtonSlideIn(fromRight:Bool = true){ | |
if(fromRight){ | |
myButton.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: 15).isActive = true | |
myButton.frame.origin.x = UIScreen.main.bounds.width | |
}else{ | |
myButton.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: -15).isActive = true | |
myButton.frame.origin.x = -80 | |
} | |
var destX = UIScreen.main.bounds.width - (80 - 15) | |
if(!fromRight){ | |
destX = -15 | |
} | |
let layer = myButton.layer | |
UIViewPropertyAnimator(duration: 0.5, curve: .easeIn, animations: { | |
layer.frame.origin.x = destX | |
}).startAnimation() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment