我有一個白色圖像按鈕。當我點擊時,它應該通過從底部到頂部的動畫變成黃色按鈕圖像,如果我再次單擊黃色按鈕圖像,它必須從上到下進行動畫,並更改爲白色圖像按鈕圖像。帶動畫的UIButton圖像按鈕
這是我的嘗試:
float originalY = btn.frame.origin.y;
float originalH = btn.bounds.size.height;
[UIView animateWithDuration:3.0f delay:1.0f options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
btn.frame = CGRectMake(btn.frame.origin.x, (originalY + originalH), btn.bounds.size.width, 0);
[btn setBackgroundImage:[UIImage imageNamed:@"yellowimg.png"] forState:UIControlStateNormal];
[btn setTitleColor:[[UIColor alloc]initWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0] forState:UIControlStateNormal];
}
completion:^(BOOL finished) {
}];
@Prateek:我曾嘗試與一個我更新,實際上我需要兩個按鈕圖像之間的動畫。 – Preethi