1

간단한 버튼을 만들어 크기를 변경하고 확장 한 다음 후속 클릭에서 축소하려고합니다.iPhone UIButton 뒤집기 및 펼치기

플립 후 마지막 버튼이 올바르게 보입니다. 원형이며 다른 크기입니다. 문제는 전환 과정에서 이상한 비 원형 효과가 발생한다는 것입니다. 이 문제를 시각적으로 보려면이 링크 ->http://screencast.com/t/rJaSJ0nGq을 참조하십시오.

전환을 원활하게 만들고 항상 원형으로 보이게하려면 어떻게해야합니까? 나는 screencast에있는 둥근 사각형 모양을 원하지 않습니다. ->https://github.com/ole/OBShapedButton 나는이 발견 결국

// Handle when a user presses the button 
- (IBAction)bubblePressed:(id)sender { 

    // Expand the bubble if it's pressed or de-expand it if 
    // already expanded 
    if (buttonResized) { 

     CGRect tempFrame=self.expandMe.frame; 
     tempFrame.size.width=100;//change acco. how much you want to expand 
     tempFrame.size.height=100; 
     [UIView beginAnimations:@"" context:nil]; 
     [UIView setAnimationDuration:BUTTON_FLIP_TIME]; 
     self.expandMe.frame=tempFrame; 

     // Round the buttons 
     self.expandMe.clipsToBounds = YES; 
     self.expandMe.layer.cornerRadius = self.expandMe.frame.size.width/2;//half of the width 
     self.expandMe.layer.borderColor=[UIColor clearColor].CGColor; 
     self.expandMe.layer.borderWidth=2.0f; 

     // Flip the button 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.expandMe cache:YES]; 

     [UIView commitAnimations]; 

    } 
    else { 

     CGRect tempFrame=self.expandMe.frame; 
     tempFrame.size.width=200;//change acco. how much you want to expand 
     tempFrame.size.height=200; 
     [UIView beginAnimations:@"" context:nil]; 
     [UIView setAnimationDuration:BUTTON_FLIP_TIME]; 
     self.expandMe.frame=tempFrame; 

     // Round the buttons 
     self.expandMe.clipsToBounds = YES; 
     self.expandMe.layer.cornerRadius = self.expandMe.frame.size.width/2;//half of the width 
     self.expandMe.layer.borderColor=[UIColor clearColor].CGColor; 
     self.expandMe.layer.borderWidth=2.0f; 

     // Flip the button 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.expandMe cache:YES]; 

     [UIView commitAnimations]; 

    } 

    // Flip the variable that tracks flipping 
    buttonResized = !buttonResized; 

} 
+0

이'self.expandMe.layer.cornerRadius = self.expandMe.frame.size.width/2'는 충분히 비 원형이 될 수 있다고 생각합니다. 원으로 바뀌는 사각형을 상상해보십시오. 비선형 프로세스 여야합니다. – BabyPanda

답변

0

:

은 여기 내 버튼을 클릭하는 방법입니다. 그것은 훌륭한 수업이고 MIT는 면허가 있습니다.