我有一个像下拉的图像。最初它会看起来像下拉图像所以当用户按下拉列表时,会显示一些选项。所以我需要的是,当下拉是真实的。我的意思是,当用户按下下拉图像,当选项列表显示时,我需要显示下拉的图像180度。像是当下拉是假的需要将图像显示为正常位置。将图像旋转180度
这种方式是正确的,而不是使用一个更多的图像?我使用SWIFT 2.2
更新时间:
@IBAction func dropBtnPress(sender: AnyObject) {
if dropDown.hidden {
dropDown.show()
UIView.animateWithDuration(0.0, animations: {
self.image.transform = CGAffineTransformMakeRotation((180.0 * CGFloat(M_PI))/180.0)
})
} else {
dropDown.hide()
// UIView.animateWithDuration(2.0, animations: {
// self.image.transform = CGAffineTransformMakeRotation((180.0 * CGFloat(M_PI))/-180.0)
// })
}
}
}
'(180 * X)/ 180 = x'下降(180.0 * CGFloat(M_PI))/ 180.0',并使用CGFloat(M_PI)' – Fogmeister