iOS潘多拉式底部工具栏

iOS潘多拉式底部工具栏,ios,ios7,uitoolbar,uislider,Ios,Ios7,Uitoolbar,Uislider,有人知道如何在工具栏上实现拖动功能以显示另一个视图吗?可能会在工具栏中添加一个子视图,但我不确定该如何分层或处理拖动 你需要类似的东西吗 这是一个样本 这是另一个 以下是我实现这一目标的方法: 创建工具栏 创建底部视图(应位于工具栏后面) 在工具栏上添加具有向上和向下方向的开关手势 在“目标方法”中,只需执行该动画即可上下移动 这是我几分钟前写的代码。 // add the variables UIToolbar *myToolBar; UIView *hid


有人知道如何在工具栏上实现拖动功能以显示另一个视图吗?可能会在工具栏中添加一个子视图,但我不确定该如何分层或处理拖动

你需要类似的东西吗

  • 这是一个样本

  • 这是另一个

以下是我实现这一目标的方法:

  • 创建工具栏
  • 创建底部视图(应位于工具栏后面)
  • 在工具栏上添加具有向上和向下方向的开关手势
  • 在“目标方法”中,只需执行该动画即可上下移动
这是我几分钟前写的代码。

    // add the variables
    UIToolbar *myToolBar;
    UIView *hiddenView;
    BOOL movedUP;


    -(void)addToolBar{
        [self addBottomMostHiddenView];
        UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        [self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithTitle:@"One Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        UIBarButtonItem *drag = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon-drag-64.png"] style:UIBarButtonItemStylePlain target:self   action:nil];
    drag.enabled = NO;
        UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithTitle:@"Two Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        NSArray *toolbarItems = [NSArray arrayWithObjects:one,spaceItem, drag, spaceItem , two, nil];

        myToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 430, self.view.frame.size.width, 80)];
        myToolBar.tintColor = [UIColor whiteColor];
        myToolBar.barTintColor = [UIColor colorWithRed:53.0/255.0 green:70.0/255.0 blue:103.00/255.00 alpha:1];
         [self.view addSubview:myToolBar];
        [myToolBar setItems:toolbarItems animated:YES];

        UISwipeGestureRecognizer *upGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    upGesture.direction = UISwipeGestureRecognizerDirectionUp;
        [myToolBar addGestureRecognizer:upGesture];

        UISwipeGestureRecognizer *downGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    downGesture.direction = UISwipeGestureRecognizerDirectionDown;
        [myToolBar addGestureRecognizer:downGesture];

    }


    -(void)addBottomMostHiddenView{
        hiddenView = [[UIView alloc]initWithFrame:CGRectMake(0, 510, self.view.frame.size.width, 40)];
        UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconProgress.png"]];
        [hiddenView addSubview:image];
        [hiddenView setBackgroundColor:[UIColor colorWithWhite:0.2 alpha:0.8]];
        [self.view addSubview:hiddenView];
    }

    -(void)dragMe:(UISwipeGestureRecognizer *)gesture {
        [UIView animateWithDuration:0.5 animations:^{
            if(gesture.direction == UISwipeGestureRecognizerDirectionDown) {
                if(movedUP) {
                    myToolBar.frame = CGRectMake(0, 430, self.view.frame.size.width, 80);
                    hiddenView.frame = CGRectMake(0, 510, self.view.frame.size.width, 80);
                    movedUP = NO;
                }
        }else  if(gesture.direction == UISwipeGestureRecognizerDirectionUp) {
            if(!movedUP) {
                myToolBar.frame = CGRectMake(0, 390, self.view.frame.size.width, 80);
                hiddenView.frame = CGRectMake(0, 470, self.view.frame.size.width, 80);
                movedUP = YES;
            }
        }
    }];

}

希望对你有帮助。

你需要类似的东西吗

  • 这是一个样本

  • 这是另一个

以下是我实现这一目标的方法:

  • 创建工具栏
  • 创建底部视图(应位于工具栏后面)
  • 在工具栏上添加具有向上和向下方向的开关手势
  • 在“目标方法”中,只需执行该动画即可上下移动
这是我几分钟前写的代码。

    // add the variables
    UIToolbar *myToolBar;
    UIView *hiddenView;
    BOOL movedUP;


    -(void)addToolBar{
        [self addBottomMostHiddenView];
        UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        [self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithTitle:@"One Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        UIBarButtonItem *drag = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon-drag-64.png"] style:UIBarButtonItemStylePlain target:self   action:nil];
    drag.enabled = NO;
        UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithTitle:@"Two Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        NSArray *toolbarItems = [NSArray arrayWithObjects:one,spaceItem, drag, spaceItem , two, nil];

        myToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 430, self.view.frame.size.width, 80)];
        myToolBar.tintColor = [UIColor whiteColor];
        myToolBar.barTintColor = [UIColor colorWithRed:53.0/255.0 green:70.0/255.0 blue:103.00/255.00 alpha:1];
         [self.view addSubview:myToolBar];
        [myToolBar setItems:toolbarItems animated:YES];

        UISwipeGestureRecognizer *upGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    upGesture.direction = UISwipeGestureRecognizerDirectionUp;
        [myToolBar addGestureRecognizer:upGesture];

        UISwipeGestureRecognizer *downGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    downGesture.direction = UISwipeGestureRecognizerDirectionDown;
        [myToolBar addGestureRecognizer:downGesture];

    }


    -(void)addBottomMostHiddenView{
        hiddenView = [[UIView alloc]initWithFrame:CGRectMake(0, 510, self.view.frame.size.width, 40)];
        UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconProgress.png"]];
        [hiddenView addSubview:image];
        [hiddenView setBackgroundColor:[UIColor colorWithWhite:0.2 alpha:0.8]];
        [self.view addSubview:hiddenView];
    }

    -(void)dragMe:(UISwipeGestureRecognizer *)gesture {
        [UIView animateWithDuration:0.5 animations:^{
            if(gesture.direction == UISwipeGestureRecognizerDirectionDown) {
                if(movedUP) {
                    myToolBar.frame = CGRectMake(0, 430, self.view.frame.size.width, 80);
                    hiddenView.frame = CGRectMake(0, 510, self.view.frame.size.width, 80);
                    movedUP = NO;
                }
        }else  if(gesture.direction == UISwipeGestureRecognizerDirectionUp) {
            if(!movedUP) {
                myToolBar.frame = CGRectMake(0, 390, self.view.frame.size.width, 80);
                hiddenView.frame = CGRectMake(0, 470, self.view.frame.size.width, 80);
                movedUP = YES;
            }
        }
    }];

}

希望对你有帮助。

你需要类似的东西吗

  • 这是一个样本

  • 这是另一个

以下是我实现这一目标的方法:

  • 创建工具栏
  • 创建底部视图(应位于工具栏后面)
  • 在工具栏上添加具有向上和向下方向的开关手势
  • 在“目标方法”中,只需执行该动画即可上下移动
这是我几分钟前写的代码。

    // add the variables
    UIToolbar *myToolBar;
    UIView *hiddenView;
    BOOL movedUP;


    -(void)addToolBar{
        [self addBottomMostHiddenView];
        UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        [self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithTitle:@"One Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        UIBarButtonItem *drag = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon-drag-64.png"] style:UIBarButtonItemStylePlain target:self   action:nil];
    drag.enabled = NO;
        UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithTitle:@"Two Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        NSArray *toolbarItems = [NSArray arrayWithObjects:one,spaceItem, drag, spaceItem , two, nil];

        myToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 430, self.view.frame.size.width, 80)];
        myToolBar.tintColor = [UIColor whiteColor];
        myToolBar.barTintColor = [UIColor colorWithRed:53.0/255.0 green:70.0/255.0 blue:103.00/255.00 alpha:1];
         [self.view addSubview:myToolBar];
        [myToolBar setItems:toolbarItems animated:YES];

        UISwipeGestureRecognizer *upGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    upGesture.direction = UISwipeGestureRecognizerDirectionUp;
        [myToolBar addGestureRecognizer:upGesture];

        UISwipeGestureRecognizer *downGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    downGesture.direction = UISwipeGestureRecognizerDirectionDown;
        [myToolBar addGestureRecognizer:downGesture];

    }


    -(void)addBottomMostHiddenView{
        hiddenView = [[UIView alloc]initWithFrame:CGRectMake(0, 510, self.view.frame.size.width, 40)];
        UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconProgress.png"]];
        [hiddenView addSubview:image];
        [hiddenView setBackgroundColor:[UIColor colorWithWhite:0.2 alpha:0.8]];
        [self.view addSubview:hiddenView];
    }

    -(void)dragMe:(UISwipeGestureRecognizer *)gesture {
        [UIView animateWithDuration:0.5 animations:^{
            if(gesture.direction == UISwipeGestureRecognizerDirectionDown) {
                if(movedUP) {
                    myToolBar.frame = CGRectMake(0, 430, self.view.frame.size.width, 80);
                    hiddenView.frame = CGRectMake(0, 510, self.view.frame.size.width, 80);
                    movedUP = NO;
                }
        }else  if(gesture.direction == UISwipeGestureRecognizerDirectionUp) {
            if(!movedUP) {
                myToolBar.frame = CGRectMake(0, 390, self.view.frame.size.width, 80);
                hiddenView.frame = CGRectMake(0, 470, self.view.frame.size.width, 80);
                movedUP = YES;
            }
        }
    }];

}

希望对你有帮助。

你需要类似的东西吗

  • 这是一个样本

  • 这是另一个

以下是我实现这一目标的方法:

  • 创建工具栏
  • 创建底部视图(应位于工具栏后面)
  • 在工具栏上添加具有向上和向下方向的开关手势
  • 在“目标方法”中,只需执行该动画即可上下移动
这是我几分钟前写的代码。

    // add the variables
    UIToolbar *myToolBar;
    UIView *hiddenView;
    BOOL movedUP;


    -(void)addToolBar{
        [self addBottomMostHiddenView];
        UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        [self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *one = [[UIBarButtonItem alloc] initWithTitle:@"One Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        UIBarButtonItem *drag = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon-drag-64.png"] style:UIBarButtonItemStylePlain target:self   action:nil];
    drag.enabled = NO;
        UIBarButtonItem *two = [[UIBarButtonItem alloc] initWithTitle:@"Two Item" style:UIBarButtonItemStylePlain    target:self     action:nil];
        NSArray *toolbarItems = [NSArray arrayWithObjects:one,spaceItem, drag, spaceItem , two, nil];

        myToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 430, self.view.frame.size.width, 80)];
        myToolBar.tintColor = [UIColor whiteColor];
        myToolBar.barTintColor = [UIColor colorWithRed:53.0/255.0 green:70.0/255.0 blue:103.00/255.00 alpha:1];
         [self.view addSubview:myToolBar];
        [myToolBar setItems:toolbarItems animated:YES];

        UISwipeGestureRecognizer *upGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    upGesture.direction = UISwipeGestureRecognizerDirectionUp;
        [myToolBar addGestureRecognizer:upGesture];

        UISwipeGestureRecognizer *downGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(dragMe:)];
    downGesture.direction = UISwipeGestureRecognizerDirectionDown;
        [myToolBar addGestureRecognizer:downGesture];

    }


    -(void)addBottomMostHiddenView{
        hiddenView = [[UIView alloc]initWithFrame:CGRectMake(0, 510, self.view.frame.size.width, 40)];
        UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconProgress.png"]];
        [hiddenView addSubview:image];
        [hiddenView setBackgroundColor:[UIColor colorWithWhite:0.2 alpha:0.8]];
        [self.view addSubview:hiddenView];
    }

    -(void)dragMe:(UISwipeGestureRecognizer *)gesture {
        [UIView animateWithDuration:0.5 animations:^{
            if(gesture.direction == UISwipeGestureRecognizerDirectionDown) {
                if(movedUP) {
                    myToolBar.frame = CGRectMake(0, 430, self.view.frame.size.width, 80);
                    hiddenView.frame = CGRectMake(0, 510, self.view.frame.size.width, 80);
                    movedUP = NO;
                }
        }else  if(gesture.direction == UISwipeGestureRecognizerDirectionUp) {
            if(!movedUP) {
                myToolBar.frame = CGRectMake(0, 390, self.view.frame.size.width, 80);
                hiddenView.frame = CGRectMake(0, 470, self.view.frame.size.width, 80);
                movedUP = YES;
            }
        }
    }];

}

希望这能对你有所帮助。

请以计算方式设置框架,而不是硬编码方式。我这样做只是为了给你线索。请以计算方式设置框架,而不是硬编码方式。我这样做只是为了给你线索。请以计算方式设置框架,而不是硬编码方式。我这样做只是为了给你线索。亲切我用计算的方式而不是硬编码的方式来设置框架。我这样做只是为了给你线索。