5

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

在此处输入图像描述

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

这是代码 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);    
4

1 回答 1

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 = 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);  
于 2018-11-05T12:23:19.620 回答