2013-05-10 51 views

回答

0

讓我們試試這個

UIButton *button; 

button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
[button setTitle:@"Show View" forState:UIControlStateNormal]; 
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); 
[self.view addSubview:button]; 

CABasicAnimation *halfTurn; 
halfTurn = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
halfTurn.fromValue = [NSNumber numberWithFloat:0]; 
halfTurn.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)]; 
halfTurn.duration = 0.5; 
halfTurn.repeatCount = HUGE_VALF; 
[[button layer] addAnimation:halfTurn forKey:@"180"]; 
0

如果你真的想使用外部庫,那麼這可能是更好的選擇。我已經完成了使用旋轉木馬庫。請參考以下鏈接https://github.com/nicklockwood/iCarousel。這很容易,更好實施。您可以將按鈕視圖添加爲輪播視圖中的項目。

+0

我如何使用此旋轉圓形時尚按鈕? – 2013-05-10 09:50:55

+0

你用過那個嗎?你必須爲此使用iCarouselTypeWheel。你不必爲旋轉做任何事情。你只需要給視圖組件。你必須使用[carousel scrollToItemAtIndex:animated: – 2013-05-10 10:03:31

0

你想旋轉整個圓或只有特定的按鈕不清楚你的問題。如果你想旋轉圓整隻使用CALayer動畫類實現this.Just設置按鈕框架,並與旋轉