gpt4 book ai didi

ios - Path 2.0菜单动画xcode

转载 作者:可可西里 更新时间:2023-11-01 04:59:27 25 4
gpt4 key购买 nike

我已经从 https://github.com/yourabi/PathMenuExample/downloads 下载了 Menu Path 2.0 .“添加”按钮可以展开和折叠菜单项数组(沿曲线绘制的动画菜单)。

enter image description here

但我想让这些按钮在一条直线上展开/折叠。

这是代码ExpandableNavigation.m:

- (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);

关于ios - Path 2.0菜单动画xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15134683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com