ios – Path 2.0菜单动画xcode
发布时间:2020-12-14 19:03:25 所属栏目:百科 来源:网络整理
导读:我从 https://github.com/yourabi/PathMenuExample/downloads下载了Menu Path 2.0. “添加”按钮使扩展和扩展折叠一系列菜单项(沿曲线绘制的动画菜单). 但我想让这些按钮直线扩展/折叠. 这是代码 ExpandableNavigation.m: - (void) expand {transition = YE
我从
https://github.com/yourabi/PathMenuExample/downloads下载了Menu Path 2.0.
“添加”按钮使扩展和扩展折叠一系列菜单项(沿曲线绘制的动画菜单). 但我想让这些按钮直线扩展/折叠. 这是代码 - (void) expand { transition = YES; [UIView animateWithDuration:self.speed animations:^{ self.mainButton.transform = CGAffineTransformMakeRotation( 45.0 * M_PI/180 ); }]; for (UIView* view in self.menuItems) { int index = [self.menuItems indexOfObject:view]; CGFloat oneOverCount = self.menuItems.count + 50<=1?1.0:(1.0/(self.menuItems.count-1)); CGFloat indexOverCount = index *oneOverCount; CGFloat rad =(1.0 - indexOverCount) * 90.0 * M_PI/180; CGAffineTransform rotation = CGAffineTransformMakeRotation( rad ) ; CGFloat x = (self.radius + self.bounce * self.radius ) * rotation.a; CGFloat y = (self.radius + self.bounce * self.radius ) * rotation.c; CGPoint center = CGPointMake( view.center.x + x,view.center.y + y); 解决方法
对于将来的任何需求,请根据所需的转换角度更改角度.
- (void) expand { transition = YES; [UIView animateWithDuration:self.speed animations:^{ self.mainButton.transform = CGAffineTransformMakeRotation( 45.0 * M_PI/180 ); }]; for (UIView* view in self.menuItems) { int index = [self.menuItems indexOfObject:view]; CGFloat oneOverCount = self.menuItems.count + 50<=1?1.0:(1.0/(self.menuItems.count-1)); CGFloat indexOverCount = index *oneOverCount; CGFloat rad =(1.0 - indexOverCount) * 90.0 * M_PI/180; CGAffineTransform rotation = CGAffineTransformMakeRotation( rad ) ; CGFloat x = yourDesired_X; //should be same for all menu items CGFloat y = (view.frame.size.hieght+8.0)*index; //Y should be increasing or decreasing for every item CGPoint center = CGPointMake(x,y); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |