在我的应用程序中,我有一个带有UIButton子视图的UIView。在viewDidLoad中,我隐藏了一个自定义视图。当用户单击某个按钮时,该视图应与按钮一起显示。它工作正常,但按钮不再可选。动画后我再也无法与它互动了。什么可能是错的?这是代码。 viewDidLoad中:
view = [[UIView alloc] initWithFrame:CGRectMake(-150, 0, 150, [[UIScreen mainScreen] bounds].size.height)];
[view setBackgroundColor:[UIColor clearColor]];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:view.frame];
imageView.image = effectImage;
[view addSubview:imageView];
[self.view addSubview:view];
UIButton *remove = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 170, [[UIScreen mainScreen] bounds].size.height)];
[remove setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:remove];
另一种方法中的动画:
[UIView animateWithDuration:0.5 animations:^{
[view setFrame:CGRectMake(150, 0, 150, [[UIScreen mainScreen] bounds].size.height)];
}];
我个人没有发现任何错误。有什么帮助吗?
答案 0 :(得分:0)
您的UIView
和UIButton
似乎重叠20像素,因为按钮宽度为170,视图位于150的x坐标。因此您可能需要将按钮置于前面。
[self.view bringSubviewToFront:remove];
或
[UIView animateWithDuration:0.5 animations:^{
[view setFrame:CGRectMake(150, 0, 150, [[UIScreen mainScreen] bounds].size.height)];
[self.view sendSubviewToBack:view];
}];