我正在尝试制作一个简单的按钮来更改大小并扩展,然后在随后的点击中缩小。
它有点工作,翻转后的最后一个按钮看起来是正确的 - 它是圆形的并且大小不同。问题是在过渡期间,我得到了这种奇怪的非圆形效果。请参阅此链接以了解此问题 -> http://screencast.com/t/rJaSJ0nGq。
如何使过渡平滑并始终看起来是圆形的?我不想要截屏视频中出现的圆角矩形外观。
这是我的按钮单击方法:
// 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;
}