SwiftCommon之Message弹窗

Easter79
• 阅读 529

概述

Message弹窗很多情况都需要用到,一个提示信息,一个错误信息等等。在IOS8中,使用UIAlertController类来管理弹窗。

SCMessage

import Foundation
import UIKit

public typealias SCMessageBoxStyle = UIAlertControllerStyle
public typealias SCMessageBoxActionStyle = UIAlertActionStyle

public class SCMessageBox{

    /**
    获取UIAlertController对象
    
    :param: title      标题提示内容
    :param: contentMsg 主要信息内容
    :param: boxStyle   窗口样式:Alert或者ActionSheet
    
    :returns: <#return value description#>
    */
    public class func boxController(title:String,contentMsg:String,boxStyle:SCMessageBoxStyle)->UIAlertController{
        return UIAlertController(title: title, message: contentMsg, preferredStyle: boxStyle)
    }
    
    /**
    获取指定的UIAlertAction对象
    
    :param: buttonString   按钮文本内容
    :param: boxActionStyle 按钮类型
    :param: blockHandler   点击按钮后的事件回调方法
    
    :returns: <#return value description#>
    */
    public class func boxAction(buttonString:String,boxActionStyle:SCMessageBoxActionStyle,blockHandler:((UIAlertAction!) -> Void)!) -> UIAlertAction{
        return UIAlertAction(title: buttonString, style: boxActionStyle, handler: blockHandler)
    }

    /**
    显示一个Alert弹窗
    
    :param: viewControl  需要显示的页面(常用Self表示当前viewControl)
    :param: title        弹窗的标题文本内容
    :param: contentMsg   弹窗的主要内容
    :param: buttonString 按钮的文本内容
    :param: blockHandler 按钮点击事件的回调方法
    */
    public class func show(viewControl:UIViewController,title:String,contentMsg:String,buttonString:String,blockHandler:((UIAlertAction!) -> Void)!){
        let control = self.boxController(title, contentMsg: contentMsg, boxStyle: SCMessageBoxStyle.Alert)
        let action  = self.boxAction(buttonString, boxActionStyle: SCMessageBoxActionStyle.Default, blockHandler: blockHandler)
        control.addAction(action)
        viewControl.presentViewController(control, animated: true, completion: nil)
    }
    /**
    快速显示一个Alert弹窗(title=提示,buttonString=确认)

    :param: viewControl 需要显示的页面
    :param: contentMsg  弹窗的主要内容
    */
    public class func showquick(viewControl:UIViewController,contentMsg:String){
        self.show(viewControl, title: "提示", contentMsg: contentMsg, buttonString: "确认", blockHandler: nil)
    }
    
}

Git地址

http://devonios.com/go/swiftcommon

tips:

本文由wp2blog导入,原文链接:http://devonios.com/scmessage.html

点赞
收藏
评论区
推荐文章
冴羽 冴羽
2年前
搭建 VuePress 博客,你可能会用到的一些插件
前言在中,我们使用VuePress搭建了一个博客,最终的效果查看:。为了丰富站点的功能,我们可以直接使用一些现有的插件,本篇我们讲讲一些常用的插件。1.公告栏弹窗插件地址:安装:bashyarnadd@vuepressreco/vuepresspluginbulletinpopoverD使用:javascriptplugins:注意事项:查
Easter79 Easter79
2年前
vue 使用element
使用elementui中的Notification,只有一个message属性是有很大的操作空间,其余的都是写死的,无法进行扩展,达不到想要的效果。所以只能在message上下功夫。在elementui官方文档中可以看到Notification中的message属性是可以处理VNode的所以我们可以使用VNode来达到我们需要的效果。如何关闭通知
LinMeng LinMeng
1年前
Vue3学习笔记之---新的组件
新的组件Fragment片段在Vue2中:组件必须要有一个根标签在Vue3中:组件可以没有根标签,内部会将多个标签包含在一个Fragment虚拟元素中好处:减少标签层级,较少内存占用Teleport瞬间移动,传送什么事Teleport?Teleport是一种能够将我们的组件html结构移动到指定位置的技术点我弹窗我是一个弹窗内容1
Easter79 Easter79
2年前
vue 弹窗式 滑动图片验证码
效果图:!(https://oscimg.oschina.net/oscnet/b752f73a444f2bcb7cc4d21a9ccab54c68f.png)具体代码:test.vue//整个页面是个弹窗visible控制弹窗的显示关闭默认打开<template<divclass
Stella981 Stella981
2年前
Android 经典笔记七 全局弹窗Dialog
目录介绍1.全局弹窗分析2.全局弹窗必要条件3.全局弹窗实现方式3.1.利用系统弹出dialog3.2.获取WindowManager,直接添加view3.3.在服务里,获取栈顶的Activity,弹窗4.Dialog实现全局Loading加载框4.1.自定义Loading类4.2.给自定义的
Stella981 Stella981
2年前
RabbitMQ 高可用之镜像队列
<p如果RabbitMQ集群只有一个broker节点,那么该节点的失效将导致整个服务临时性的不可用,并且可能会导致message的丢失(尤其是在非持久化message存储于非持久化queue中的时候)。可以将所有message都设置为持久化,并且使用持久化的queue,但是这样仍然无法避免由于缓存导致的问题:因为message在发送之后和被写入磁盘并执行f
Stella981 Stella981
2年前
Spring MVC Validation 统一处理
SpringMVCValidation用到JSR349,一个通用的规范,使用hibernate的实现,规则比较全。DtopublicclassUserDto{@NotEmpty(groups{GroupA.class},message"01111|ID不能为空")
Stella981 Stella981
2年前
Layer 关闭弹窗
var index  parent.layer.getFrameIndex(window.name); //获取窗口索引parent.layer.close(index);layer.open({                            type : 2,                            skin : '
Stella981 Stella981
2年前
MyEclipse2014 Update Progress弹窗频繁出现的问题解决
备注20170825:实际验证该效果只适合开始的时候,时间长了还是会蹦出弹窗,目前出现弹窗后本人是直接将之最小化到左下角,基本不会干扰.这两天开始使用MyEclipse2014之后,UpdateProgress弹窗更加频繁,十分烦人.上网上搜了很多方法,适用性较差,结合实验直接将自己的方法给出:1.关掉在打开的MyEclipse2014;2
京东云开发者 京东云开发者
11个月前
618技术揭秘 - 大促弹窗搭投实践 | 京东云技术团队
618大促来了,对于业务团队来说,最重要的事情莫过于各种大促营销。如会场、直播带货、频道内营销等等。而弹窗作为一个极其重要的强触达营销工具,通常用来渲染大促氛围、引流主会场、以及通过频道活动来提升频道复访等。因此,如果能将运营的策略及想法快速转化为弹窗的内容并触达给用户,这对于提升运营效率及玩法灵活性的是极其有意义的。
Easter79
Easter79
Lv1
今生可爱与温柔,每一样都不能少。
文章
2.8k
粉丝
5
获赞
1.2k