iOS 模态弹出(Modal)

  • 模态视图出现的场景一般是临时弹出的窗口,譬如:登陆窗口。
  • 以模态窗口的形式管理视图,当前视图关闭前其他视图上的内容无法操作。
1、弹出方法:presentModalViewController:
  • 由 视图控制器类对象调用presentModalViewController:   方法。

2、modalTransitionStyle属性

  • 模态视图弹出时可通过该属性设置不同的动画效果 ,包含类型如下:
  • UIModalTransitionStyleCoverVertical,  //自下而上
  • UIModalTransitionStyleFlipHorizontal, //自左至右180度翻转
  • UIModalTransitionStyleCrossDissolve, //淡出效果
  • UIModalTransitionStylePartialCurl //翻页效果
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是一个简单的例子,演示如何使用 JavaScript 创建一个弹出模态框: ```html <!DOCTYPE html> <html> <head> <title>Modal Example</title> <style> .modal { display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); } .modal-content { background-color: white; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 80%; } .close { color: #aaa; float: right; font-size: 28px; font-weight: bold; } .close:hover, .close:focus { color: black; text-decoration: none; cursor: pointer; } </style> </head> <body> <h2>Modal Example</h2> <!-- Button to open the modal --> <button onclick="openModal()">Open Modal</button> <!-- The Modal --> <div id="myModal" class="modal"> <!-- Modal content --> <div class="modal-content"> <span class="close" onclick="closeModal()">×</span> <p>This is a modal.</p> </div> </div> <script> var modal = document.getElementById("myModal"); // When the user clicks the button, open the modal function openModal() { modal.style.display = "block"; } // When the user clicks on <span> (x), close the modal function closeModal() { modal.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } </script> </body> </html> ``` 此代码将创建一个按钮,当单击该按钮时,将显示一个模态框。模态框的内容可以在 `<div class="modal-content">` 中添加。关闭按钮使用 `<span class="close">` 元素,并在 JavaScript 中添加了一个 `onclick` 事件侦听器,以便单击关闭按钮后关闭模态框。还添加了一个 `window.onclick` 事件侦听器,以便在单击模态框外的任何地方时关闭模态框。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值