[英]How to perform different segue based on condition from a button click in swift?
[英]how to perform same animation with different points on button click ios Swift
我正在嘗試通過單擊按鈕上的動畫來提高溫度,這是在我第一次點擊按鈕時起作用的,但是當我再次點擊按鈕時,什么也沒有發生。 我正在使用圖像視圖(紅色)顯示溫度,這是我在后台操作中使用的代碼 ] 2
UIView.animateWithDuration(3.0, animations: {
self.progress.transform = CGAffineTransformMakeTranslation((self.progress.frame.origin.x -self.progress.frame.origin.x ), -30)
})
每當我單擊+按鈕時,它應該增加,但是沒有發生,誰能解釋這是什么問題?
如果僅移動框架,則不一定需要CGAffineTransformMakeTranslation。 只需將新框架設置為視圖即可完成相同操作。 另外,如果您不在任何地方重設轉換,則第二次沒有動畫可設置。 或者,而不是重置,您應該增加/減少值-30,而不是每次都使用相同的值。
要移動圖像,您應該對轉換進行串聯
UIView.animateWithDuration(3.0, animations: {
let transform = CGAffineTransformMakeTranslation(0, -30)
self.progress.transform = CGAffineTransformConcat(self.progress.transform, transform)
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.