我正在尝试创建一个应用程序(对于ipad),它可以显示两个彼此相邻的视图,并且可以通过UISlider
调整大小,只需将Value从0更改为屏幕宽度(1024)就像这样
width = 512,这使得主视图分为两个视图,一个等于另一个视图
我的问题是如何通过UISlider
用户调整这些视图的大小
我试过这个
viewResizer
是UISlider
- (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{
}
}
答案 0 :(得分: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)];
}