返回

iOS 自定义 UIAlertController,释放你的弹窗自由!

Android

自定义弹窗,尽情释放你的想象力:QUIAlerController 来了!

在 iOS 开发的世界中,我们经常需要使用弹窗来与用户进行交互。虽然系统提供的 UIAlertController 功能强大,但有时候却无法满足我们个性化的需求。想象一下,如果你可以自定义弹窗页面的间距、弹出 XibView 或 ViewController,甚至是全屏展示一张大图或一段长文,那该有多棒!

QUIAlerController,弹窗自由的新天地

现在,QUIAlerController 来了!它是一款功能强大的 UIAlertController 替代方案,让你尽情释放弹窗自由。它不仅提供了强大的自定义功能,还开源免费,让你轻松打造出个性化十足、交互丰富的弹窗体验。

特性一览

  • 随心所欲自定义页面间距:告别系统固定的间距限制,你可以根据自己的喜好调整页面各个元素之间的距离,打造独一无二的弹窗界面。
  • 灵活弹出 XibView:不再局限于文字和按钮,你可以将 XibView 作为弹窗内容,尽情发挥你的创意,打造交互丰富、视觉惊艳的弹窗。
  • 无缝集成 ViewController:想要在弹窗中嵌入完整的 ViewController?没问题!QUIAlerController 让你轻松实现,让弹窗功能更加强大。
  • 支持全屏弹窗:需要展示一张大图或一段长文?使用全屏弹窗模式,让你的内容占据整个屏幕,带来更加震撼的视觉体验。
  • 开源免费,任你使用:QUIAlerController 是一个开源项目,你可以免费使用、修改和分发,让你的弹窗设计不再受限。

安装

通过 CocoaPods 安装:

pod 'QUIAlertController'

使用指南

基本用法

let alert = QUIAlertController(title: "提示", message: "这是一个自定义的弹窗")
alert.addAction(title: "确定", style: .default) { _ in
    print("点击了确定按钮")
}
alert.addAction(title: "取消", style: .cancel) { _ in
    print("点击了取消按钮")
}
present(alert, animated: true)

自定义页面间距

let alert = QUIAlertController(title: "提示", message: "这是一个自定义的弹窗")
alert.contentInsets = UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 10)

弹出 XibView

let xibView = UINib(nibName: "MyXibView", bundle: nil).instantiate(withOwner: nil, options: nil).first as! UIView
let alert = QUIAlertController(customView: xibView)

弹出 ViewController

let vc = MyViewController()
let alert = QUIAlertController(contentViewController: vc)

全屏弹窗

let alert = QUIAlertController(title: "提示", message: "这是一个全屏弹窗", style: .fullScreen)

开源地址

欢迎访问 GitHub 查看更多信息和示例:https://github.com/QDong415/QUIAlertController

常见问题解答

1. QUIAlerController 和 UIAlertController 有什么区别?

QUIAlerController 是一款 UIAlertController 的替代方案,它提供了更强大的自定义功能,包括自定义页面间距、弹出 XibView、集成 ViewController 和全屏弹窗等。

2. QUIAlerController 如何自定义页面间距?

QUIAlerController 提供了 contentInsets 属性,你可以通过它调整页面各个元素之间的距离,打造更加个性化的弹窗界面。

3. QUIAlerController 如何弹出 XibView?

QUIAlerController 提供了 customView 属性,你可以将 XibView 作为弹窗内容,尽情发挥你的创意,打造交互丰富、视觉惊艳的弹窗。

4. QUIAlerController 如何弹出 ViewController?

QUIAlerController 提供了 contentViewController 属性,你可以将 ViewController 作为弹窗内容,轻松实现弹窗中嵌入完整 ViewController 的功能,让弹窗功能更加强大。

5. QUIAlerController 是否开源免费?

是的,QUIAlerController 是一个开源项目,你可以免费使用、修改和分发,让你的弹窗设计不再受限。

结语

告别系统 UIAlertController 的束缚,使用 QUIAlerController 尽情释放你的弹窗自由!它不仅提供了强大的自定义功能,还开源免费,让你轻松打造出个性化十足、交互丰富的弹窗体验。快来下载体验吧,让你的 iOS 应用脱颖而出!