ios - 如何为自定义按钮添加动画并在点击按钮时调用?
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>这个问题在这里已经有了答案</b>:
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>嗨@Said Alır @AtulParmar 的回答很好,但如果您只需要在特定类型的事件(例如(touchUpInside))的情况下制作动画,请尝试以下解决方案。</p>
<pre><code>import UIKit
class MyButton: UIButton {
override func awakeFromNib() {
super.awakeFromNib()
self.addTarget(self, action: #selector(MyButton.touchUpInside), for: .touchUpInside)
}
@objc func touchUpInside() {
//Perform you animations here
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何为自定义按钮添加动画并在点击按钮时调用?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/54552666/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/54552666/
</a>
</p>
页:
[1]