我有一个功能,可以将主视图移到一侧以显示UIButton
. 视图内的按钮部分是可点击的,但按钮的右侧不是。我已将 self.view.frame 更改为更大的数字,但我仍然面临同样的问题。我也尝试过玩,insertSubview:aboveSubview:
但这也没有帮助。
self.view.frame = CGRectMake(0, 0, 1600, 568);
_testView = [[UIView alloc]initWithFrame:CGRectMake(300, 20, 120, 100)];
_testView.backgroundColor = [UIColor greenColor];
UIButton *test = [UIButton buttonWithType:UIButtonTypeRoundedRect];
test.frame = CGRectMake(0, 0, 120, 100);
[test addTarget:self action:@selector(doSomething) forControlEvents:UIControlEventTouchUpInside];
[_testView addSubview:test];
[self.view addSubview:_testView];
- (void)showRightMenu
{
CGRect frame = self.view.frame;
frame.origin.x = -100;
self.view.frame = frame
}
编辑:我已经上传了我的问题的示例项目https://dl.dropboxusercontent.com/u/137356839/TestMePlz.zip