0

我正在尝试创建一个应用程序(用于 ipad),该应用程序显示两个视图彼此相邻,并且UISlider可以通过将 Value 从 0 更改为屏幕宽度( 1024 )来调整大小,就像这样

在此处输入图像描述

width=512 这使得主视图分成两个视图一个等于另一个我的问题是如何使这些视图可以由用户调整大小UISlider 我试过了

viewResizerUISlider

- (IBAction)valueChanged:(id)sender {
    if (self.viewResizer.value >512) {
        [self.secView setFrame:CGRectMake(self.secView.frame.origin.x, self.secView.frame.origin.y,self.viewResizer.value , 660.0)];
        [self.firstView setFrame:CGRectMake(orgiX, orgiY,self.secView.frame.size.width- self.viewResizer.value , 660)];
    }else{

    }    
}
4

1 回答 1

0

例如,如果您的滑块有 1024 个值,那么您可以:

- (IBAction)valueChanged:(id)sender 
{
    //First view will be resized from 0 to sliders value, 
    [self.firstView setFrame:CGRectMake(0, 0, sender.value, 660)];

    //Second view will be resized from first views width, to 1024(parent view width)-first views width.
    [self.secView setFrame:CGRectMake(self.firstView.frame.size.width, 0, self.view.frame.size.width - self.firstView.frame.size.width, 660)];
}

然后,您可以将滑块值减少到 256(但它不会那么平滑):

- (IBAction)valueChanged:(id)sender 
{
    //First view will be resized from 0 to sliders value, 
    [self.firstView setFrame:CGRectMake(0, 0, sender.value*4, 660)];

    //Second view will be resized from first views width, to 1024(parent view width)-first views width.
    [self.secView setFrame:CGRectMake(self.firstView.frame.size.width, 0, self.view.frame.size.width - self.firstView.frame.size.width, 660)];
}
于 2013-09-24T06:36:20.283 回答