iOS开发 从下往上弹出提醒视图或日期选择视图等等背景为半透明
2017-02-04 19:30
447 查看
从下往上弹出提醒视图或日期选择视图等等,背景为半透明,弹下去时半透明慢慢消失,最后隐藏
先是背景与日期选择的初始化-(void)initTimeView{ //时间 背景 提醒视图
//背景透明黑
_blackView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, screen_width, screen_height-60)];
_blackView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer *touchBlackView = [[UITapGestureRecognizer alloc]init];
[touchBlackView addTarget:self action:@selector(hitRili)];
[_blackView addGestureRecognizer:touchBlackView];
_blackView.hidden = YES;
[self.view addSubview:_blackView];
//时间选择
_timeView = [[TimeChooseView alloc]initWithFrame:CGRectMake(0, _blackView.frame.size.height, screen_width, screen_height*6/11)];
_timeView.datepicker.datePickerMode = UIDatePickerModeDate;
_timeView.backgroundColor = [UIColor colorWithWhite:0.925 alpha:1.000];
[_timeView.sureBtn addTarget:self action:@selector(HadSelectRiLi) forControlEvents:UIControlEventTouchUpInside];
[_timeView.cancelBtn addTarget:self action:@selector(hitRili) forControlEvents:UIControlEventTouchUpInside];
[_blackView addSubview:_timeView];
}再是定义一个bool类型的show表示是否已经弹出,下面是弹出,弹入的方法
-(void)hitRili{ //日历
if (show == NO) {
[UIView animateWithDuration:0.3 animations:^{
_blackView.hidden = NO;
_timeView.frame = CGRectMake(0,_blackView.frame.size.height-screen_height*6/11-64, screen_width, screen_height*6/11);
_blackView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.440];
}];
show = YES;
}else if (show == YES){
[UIView animateWithDuration:0.3 animations:^{
_timeView.frame = CGRectMake(0, _blackView.frame.size.height, screen_width, screen_height*6/11);
_blackView.backgroundColor = [UIColor clearColor];
}completion:^(BOOL finished)
{
_blackView.hidden = YES;
}];
show = NO;
}
}可以实现渐渐弹出弹入
如果一开始存在输入框或者textview 需要用
[self.view endEditing:YES];来提高效果。
先是背景与日期选择的初始化-(void)initTimeView{ //时间 背景 提醒视图
//背景透明黑
_blackView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, screen_width, screen_height-60)];
_blackView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer *touchBlackView = [[UITapGestureRecognizer alloc]init];
[touchBlackView addTarget:self action:@selector(hitRili)];
[_blackView addGestureRecognizer:touchBlackView];
_blackView.hidden = YES;
[self.view addSubview:_blackView];
//时间选择
_timeView = [[TimeChooseView alloc]initWithFrame:CGRectMake(0, _blackView.frame.size.height, screen_width, screen_height*6/11)];
_timeView.datepicker.datePickerMode = UIDatePickerModeDate;
_timeView.backgroundColor = [UIColor colorWithWhite:0.925 alpha:1.000];
[_timeView.sureBtn addTarget:self action:@selector(HadSelectRiLi) forControlEvents:UIControlEventTouchUpInside];
[_timeView.cancelBtn addTarget:self action:@selector(hitRili) forControlEvents:UIControlEventTouchUpInside];
[_blackView addSubview:_timeView];
}再是定义一个bool类型的show表示是否已经弹出,下面是弹出,弹入的方法
-(void)hitRili{ //日历
if (show == NO) {
[UIView animateWithDuration:0.3 animations:^{
_blackView.hidden = NO;
_timeView.frame = CGRectMake(0,_blackView.frame.size.height-screen_height*6/11-64, screen_width, screen_height*6/11);
_blackView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.440];
}];
show = YES;
}else if (show == YES){
[UIView animateWithDuration:0.3 animations:^{
_timeView.frame = CGRectMake(0, _blackView.frame.size.height, screen_width, screen_height*6/11);
_blackView.backgroundColor = [UIColor clearColor];
}completion:^(BOOL finished)
{
_blackView.hidden = YES;
}];
show = NO;
}
}可以实现渐渐弹出弹入
如果一开始存在输入框或者textview 需要用
[self.view endEditing:YES];来提高效果。
相关文章推荐
- IOS UIAlertController 弹出框中添加视图(例如日期选择器等等)
- iOS8 UIAlertController弹出框中添加视图(例如日期选择器等等)
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程1
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程2
- iOS开发(OC)——日期选择器
- iOS一个弹出的时间选择器视图(UIDatePicker)
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程1
- iOS开发之 网页视图和时间选择器
- <转>Android开发使输入框点击弹出日期选择对话框的方法
- iOS开发-------UIAlertController(弹出视图控制器)
- iOS 自定义UIDatePicker日期选择器视图 —— HERO博客
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程3
- ios开发-凤凰网的揭层式下拉刷,如何下拉table显示其下面的视图不是背景(已解决)
- Delphi for iOS开发指南(5):在iOS应用程序中使用Calendar组件来选择日期
- iOS开发——ActionSheet的使用与弹出选择对话框
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程4
- ios开发学习-弹出视图(Popup View) 效果源码分享--系列教程2
- iOS开发学习之#提醒处理#(1)响应提醒视图
- android日期选择器,从底部弹出的日期选择器,有点像IOS日期选择器
- iOS开发UItextfile弹出日期选择控制器输入日期