![](/img/trans.png)
[英]How to automatically change transparent color of a view based on the color of it’s background
[英]How to disable background view with dark transparent color?
我为从屏幕底部滑动的uiview创建了动画,但是我希望在视图滑动到屏幕上以禁用bg视图并使用这样的暗bg:
我怎样才能做到这一点? 此外,当我点击暗透明视图时,我希望它滑出并启用bg视图。
这是我如何做滑动动画:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
} else if (buttonIndex == 1) {
self.slidingView.hidden = NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.slidingView.frame = CGRectMake(0,0,320,20);
self.view.frame = CGRectMake(0,0,320,460);
[UIView commitAnimations];
self.view.userInteractionEnabled = NO;
}
}
Thanksss
我在最近的一个项目上做了类似的事情。 不是仅添加一个包含选择器的视图的视图,而是向其添加父视图。 因此,您将添加到视图控制器的视图将是具有透明黑色背景的屏幕大小,然后使用您的自定义动画选择器将视图添加到子视图。
另一种方法是在视图控制器中创建一个最初隐藏的视图,并在显示您的选择器视图时显示它。
如果您可以分享您的代码,我可以更好地帮助您。
编辑:
- 在视图控制器中添加具有相同宽度和高度的视图,具有前导,顶部,尾部和底部约束。
- 有这个视图的出口(例如:backgroundView)
-in viewDidLoad:
添加以下行:
self.backgroundView.hidden=YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourcodeToCloseTheView)];
singleTap.numberOfTapsRequired = 1;
[self.backgroundView addGestureRecognizer:singleTap];
- 并在您的actionSheet:clickedButtonAtIndex:
添加以下行:
self.backgroundView.hidden=NO;
只需确保backgroundView位于IB中的pickerView后面。
希望有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.