[英]UIView animation change size of button
我開始嘗試從應用程序商店重新創建購買按鈕,這需要兩個階段的點擊來購買東西。 我動畫按鈕擴展。 到目前為止,我有這個
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
sender.autoresizesSubviews = NO;
sender.clipsToBounds = NO;
sender.frame = CGRectMake(63,326,200,37);
[UIView commitAnimations];
這只會導致按鈕變大,根本沒有動畫效果。 我做錯了什么或有沒有其他人實現這種類型的按鈕行為?
編輯:
- (IBAction) buyButtonAction: (UIButton *) sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelay:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
sender.clipsToBounds = NO;
sender.frame = CGRectMake( CGRectGetMinX( sender.frame) - 30, CGRectGetMinY(sender.frame), 200, 37);
[sender setTitle:@"Touched Touched Touched" forState:UIControlStateNormal];
[UIView commitAnimations];
}
您是否針對不支持Blocks的iOS?
我使用以下令人作嘔的簡單代碼實現了“觸摸按鈕動畫”。
[UIView animateWithDuration:0.5 animations:^{
self.navigationItem.rightBarButtonItem.title = @"Quoting...";
}];
或者,如果你不能支持塊,這個代碼似乎也能用於觸摸按鈕的動畫(它還包括如果你去那條路線注釋掉的塊):
-(IBAction) clicked:(UIButton*)sender{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//[UIView animateWithDuration:2.5 animations:^{
sender.autoresizesSubviews = NO;
sender.clipsToBounds = NO;
sender.frame = CGRectMake(63,326,200,37);
//sender.frame = CGRectMake( CGRectGetMinX( self.theButton.frame) - 100, CGRectGetMinY(self.theButton.frame), 300, 40);
//[sender setTitle:@"Touched Touched Touched" forState:UIControlStateNormal];
//}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.