gpt4 book ai didi

ios - 在 uibutton 内旋转 png

转载 作者:搜寻专家 更新时间:2023-11-01 06:16:04 26 4
gpt4 key购买 nike

我在 UINavigationBar 的 titleView 中有一个 UIButton。每次用户点击给定按钮时,我都想将插入符号图像向下旋转 180 度。

enter image description here

最佳答案

这是一个如何使用 Transforms 实现的示例:- 代码适用于从 UIView 继承的所有元素

UIView.animate(withDuration: 0.5) {
self.yourButton.imageView?.transform = CGAffineTransform(rotationAngle: CGFloat.pi)

}

要将其设置回原始位置:-

UIView.animate(withDuration: 0.5) {
self.yourButton.imageView?.transform = .identity)

}

关于ios - 在 uibutton 内旋转 png,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44872860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com