有 2 个视图“view1”和“view2”。
左侧视图 1 和右侧视图 2。
显示第一个 view1,然后按按钮 view2 被调用。view2 应该在 view 1 之上,但是 view1 应该被禁用,当用户点击 view1 时 view2 消失并且 view1 突出显示。
谢谢你的帮助。
我要做的是,作为一个简单的解决方案:
当View1
被按下以动画View2
到位时,在 上覆盖UIButton
透明View1
。This will cover all the subviews of View1
and when the area is selected, you animate View2
out of place and highlight View1
and remove the transparent button.
希望这是有道理的!
更新:决定提供一个简短的例子,因为它可能更有意义。
-(void)onView1ButtonPress {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:[view1 bounds]];
[button addTarget:self action:@selector(activateView1:) forControlEvents:UIControlEventAllTouchEvents];
[view1 addSubview:button];
/* your other code to bring View2 into view */
....
}
-(void)activateView1:(id)sender {
UIButton *button = (UIButton*)sender;
[button removeFromSuperview];
/* your code to make View1 Active and Animate View2 out */
....
}
理解起来有点复杂,但据我了解,您正在创建 2 个视图,并且您想让用户交互启用/禁用 .so,1. 设置标签
btnForView1.tag = 1;
btnForView2.tag = 2;
//创建另一个与view1相同帧大小的imageView并在其上设置透明图像。2.方法
-(IBAction)btnPressed:(id)发件人
{
UIbutton *btn = (UIButton *)sender; if(btn.tag == 1) { view2.userInteraction = NO; view1.userInteraction = YES; transprantImageView.hidden = NO; } else { view1.userInteraction = NO; view2.userInteraction = YES; transprantImageView.hidden = TRUE; }
}