kgmodal - 以后写个页面模态的东西弹出可直接用这个来,快

http://www.cocoacontrols.com/controls/kgmodal


GModal is an easy drop in control that allows you to display any view in a modal popup. The modal will automatically scale to fit the content view and center it on screen with nice animations!

You supply your own content view and KGModal does the rest:

[[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];

There are a couple other options but it's purposely designed to be simple and easy to use:

// Determines if the modal should dismiss if the user taps outside of the modal view
// Defaults to YES
@property (nonatomic) BOOL tapOutsideToDismiss;

// Determins if the close button or tapping outside the modal should animate the dismissal
// Defaults to YES
@property (nonatomic) BOOL animateWhenDismissed;

// Determins if the close button is shown
// Defaults to YES
@property (nonatomic) BOOL showCloseButton;

// The background color of the modal window
// Defaults black with 0.5 opacity
@property (strong, nonatomic) UIColor *modalBackgroundColor;

// The background display style, can be a transparent radial gradient or a transparent black
// Defaults to gradient, this looks better but takes a bit more time to display on the retina iPad
@property (nonatomic) enum KGModalBackgroundDisplayStyle backgroundDisplayStyle;

// The shared instance of the modal
+ (id)sharedInstance;

// Set the content view to display in the modal and display with animations
- (void)showWithContentView:(UIView *)contentView;

// Set the content view to display in the modal and whether the modal should animate in
- (void)showWithContentView:(UIView *)contentView andAnimated:(BOOL)animated;

// Hide the modal with animations
- (void)hide;

// Hide the modal with animations,
// run the completion after the modal is hidden
- (void)hideWithCompletionBlock:(void(^)())completion;

// Hide the modal and whether the modal should animate away
- (void)hideAnimated:(BOOL)animated;

// Hide the modal and whether the modal should animate away,
// run the completion after the modal is hidden
- (void)hideAnimated:(BOOL)animated withCompletionBlock:(void(^)())completion;

Check out the ExampleApp to see it in action!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然可以,以下是一个简单的登录页面模态框的例子: ```html <!-- 按钮触发模态框 --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#loginModal">登录</button> <!-- 模态框 --> <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="loginModalLabel">登录</h5> <button type="button" class="close" data-dismiss="modal" aria-label="关闭"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <!-- 登录表单 --> <form> <div class="form-group"> <label for="username">用户名</label> <input type="text" class="form-control" id="username" placeholder="请输入用户名"> </div> <div class="form-group"> <label for="password">密码</label> <input type="password" class="form-control" id="password" placeholder="请输入密码"> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button> <button type="button" class="btn btn-primary">登录</button> </div> </div> </div> </div> ``` 在这个例子中,我们使用了 Bootstrap 的模态框组件来创建一个登录页面弹出框。我们在触发模态框的按钮上添加了 `data-toggle="modal"` 和 `data-target="#loginModal"` 属性,这样点击按钮时就会触发模态框的显示。同时,我们在模态框的 HTML 代码中定义了一个 ID 为 `loginModal` 的模态框,并在按钮的 `data-target` 属性中指定了这个模态框的 ID。 在模态框的内容中,我们放置了一个登录表单,包含用户名和密码两个输入框。在模态框的页眉中,我们添加了一个关闭按钮,可以通过点击它来关闭模态框。 请注意,在这个例子中,我们使用了一些 Bootstrap 的辅助类来添加样式,如 `modal`、`modal-dialog`、`modal-content`、`modal-header`、`modal-body`、`modal-footer`、`form-group`、`form-control`、`btn` 等。这些类可以帮助你速地添加样式和布局。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值