关键词:
有些弹窗如果点击按钮的同时就出现一个弹窗就显得有的突兀,这次实现的效果是点击按钮的同时弹窗由下往上弹出来,添加了动画效果:
1、首先创建一个弹出的View类,
在HTAlertView.h中:
@property (nonatomic, strong) void (^backBtnActionBlock)(); @property (weak, nonatomic) IBOutlet UIView *myView; @property(nonatomic,strong) UIControl *huiseControl; - (void)showInView:(UIView *) view; + (instancetype)getSimpleView;
2、在HTAlertView.m中:
- (void)awakeFromNib{ _huiseControl=[[UIControl alloc]initWithFrame:CGRectMake(0, 0, UIBounds.size.width, UIBounds.size.height)]; _huiseControl.backgroundColor=RGBACOLOR(0, 0, 0, 0.4); [_huiseControl addTarget:self action:@selector(huiseControlClick) forControlEvents:UIControlEventTouchUpInside]; _huiseControl.alpha=0; self.backgroundColor = [UIColor whiteColor]; } + (instancetype)getSimpleView{ NSArray *objs = [[NSBundle mainBundle] loadNibNamed:@"HTAlertView" owner:nil options:nil]; return [objs lastObject]; } - (void)showInView:(UIView *) view { if (_huiseControl.superview==nil) { [view addSubview:_huiseControl]; } [UIView animateWithDuration:0.2 animations:^{ _huiseControl.alpha=1; }]; CATransition *animation = [CATransition animation]; animation.delegate = self; animation.duration = 0.2f; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.type = kCATransitionPush; animation.subtype = kCATransitionFromTop; [self.layer addAnimation:animation forKey:@"animation1"]; self.frame = CGRectMake(0,view.frame.size.height - 355, [UIScreen mainScreen].bounds.size.width, 355); [view addSubview:self]; } - (void)hideInView { self.hidden = YES; CATransition *animation = [CATransition animation]; animation.delegate = self; animation.duration = 0.2f; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.type = kCATransitionPush; animation.subtype = kCATransitionFromBottom; [self.layer addAnimation:animation forKey:@"animtion2"]; [UIView animateWithDuration:0.2 animations:^{ _huiseControl.alpha=0; }completion:^(BOOL finished) { [self removeFromSuperview]; [_huiseControl removeFromSuperview]; }]; } - (IBAction)btnClick:(UIButton *)sender { if (self.backBtnActionBlock) { self.backBtnActionBlock(); } } -(void)huiseControlClick{ [self hideInView]; }
其中
#define UIBounds [[UIScreen mainScreen] bounds] //window外框大小 #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]
最后在viewController中要弹窗的button实现方法即可
- (void)popupButtonClick { HTAlertView *alert = [HTAlertView getSimpleView]; alert.backBtnActionBlock = ^(){ NSLog(@"sdgvet4wfdscx"); }; [alert showInView:self.view]; }
其中有代码块可以回调得到View中的按钮触发
kotlin实现自定义下拉阴影弹窗的功能(代码片段)
实现:项目:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是方... 查看详情
自定义响应式弹窗
Html代码<!DOCTYPEhtml><html><head><metacharset="UTF-8"><scripttype="text/javascript"src="js/jquery-1.12.1.min.js"></script><scripttype="text/javascript"src=" 查看详情
kotlin实现从顶部带textview(点击取消)的弹窗的功能(代码片段)
实现:项目:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是方... 查看详情
back键和menu键程序退出弹窗以及按钮退出程序弹窗的实现
MainActivity.javapackagecom.loaderman.backmenudemo;importandroid.content.Intent;importandroid.support.v7.app.AppCompatActivity;importandroid.os.Bundle;importandroid.view.Gravity;importandroid.view.Key 查看详情
kotlin实现在activity中间弹出的list列表弹窗的功能(代码片段)
...library,如下图:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是... 查看详情
kotlin实现从底部自定义像activity一样的全屏弹窗的功能(代码片段)
...library,如下图:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是... 查看详情
kotlin实现从底部弹出带手势拖拽的列表弹窗的功能(代码片段)
...library,如下图:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是... 查看详情
kotlin实现在中间显示带标题内容输入框(带有hint名)和确认取消按钮的弹窗的功能(代码片段)
...library,如下图:温馨提示:第三方项目library里面的不同弹窗有很多:从顶部弹窗、从底部弹窗、自由定位弹窗、自定义全屏弹窗、显示旋转弹窗(动画)…,适合工作,你想改什么样的弹窗就在这项目library里直接拿就即可,就是... 查看详情
可拖动弹窗的js和jquery两种写法
...现的演示视频,这个demo中的例子是百度首页登录按钮的弹窗,如下图: 当点击左上角的登录按钮时,弹窗出现并自动居中,同时窗口可拖动的范围被限制在了可视区域内,即浏览器视窗的上下左右边... 查看详情
弹窗的淡入淡出
varsendMsgTip=function(className,$event){$event.stopPropagation();$(className).stop(true,true).fadeIn(500);$(className).stop(true,true).delay(2000).fadeOut(1000);if(!$scope.$$phase){$scope.$apply();}} 查看详情
react实现优雅的弹窗(代码片段)
实现弹窗的原理关键在于,如何将弹窗组件挂载到任意的dom上,参考weui.js,提供了思路,可以通过append将元素添加到指定的父节点上,来实现弹窗的显示,隐藏的时候在移除该元素即可,... 查看详情
react实现优雅的弹窗(代码片段)
实现弹窗的原理关键在于,如何将弹窗组件挂载到任意的dom上,参考weui.js,提供了思路,可以通过append将元素添加到指定的父节点上,来实现弹窗的显示,隐藏的时候在移除该元素即可,... 查看详情
easyui里弹窗的两种表现形式
easyui里弹窗的两种表现形式博客分类: jQueryEasyUi 1、主JSP页面中描绘弹窗 Html代码 <div id="centerDiv" data-options="region:‘center‘,border:false"> &n 查看详情
react中antd每当打开不一样的弹窗时,不能更新弹窗的内容
参考技术Aselect里面的内容是上一个弹窗里面内容。大概最主要的原因是,onChange事件里面需要写this.setState,setState本质是通过一个队列机制实现state更新的。执行setState时,会将需要更新的state合并后放入状态队列,而不会立即更... 查看详情
js写弹窗
1.先来看弹窗的模样点击“弹出窗口”后会弹出下面窗口 2.下面是实现弹出窗口的代码,其中引入的jquery一般自己有,没有的话可以从网上下载。tanchuang.js和tanchuang.css写在了下面。 弹窗的一些参数可以参考tanchuang.js里面的... 查看详情
layer弹窗的跳转功能
1,本弹窗直接跳转父页面:1@if(session(‘message‘))23<script>4window.parent.location.reload();//刷新父页面5varindex=parent.layer.getFrameIndex(window.name);//获取窗口索引6parent.layer.close(index);//关闭layer7</script& 查看详情
js中关闭弹窗的问题
先举列一个W3Cshool的例子:在父窗口关闭子窗口<html><head><scripttype="text/javascript">functioncloseWin(){alert(myWindow.name)//子窗口的名称mynamemyWindow.close()//在父页面关闭子窗口}</script></head><b 查看详情
自动化测试,headless模式下,alert弹窗的文本可以获取,但是alert弹窗该怎样截图才能把弹窗的图截出来
参考技术A模拟按键检测到弹窗时给弹窗焦点,然后模拟按下alt+print键,操作内存剪辑板内容不行吗? 参考技术B可以试试获取alert对象,调用alert对象的截图方法追问driver.switch_to.alert方法可以获取alert对象,但是alert对象怎样截图... 查看详情