1.封装 弹框
http://www.hangge.com/blog/cache/detail_651.html

import UIKit

extension UIAlertController {
//在指定视图控制器上弹出普通消息提示框
static func showAlert(message: String, in viewController: UIViewController) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "确定", style: .cancel))
viewController.present(alert, animated: true)
} //在根视图控制器上弹出普通消息提示框
static func showAlert(message: String) {
if let vc = UIApplication.shared.keyWindow?.rootViewController {
showAlert(message: message, in: vc)
}
} //在指定视图控制器上弹出确认框
static func showConfirm(message: String, in viewController: UIViewController,
confirm: ((UIAlertAction)->Void)?) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
alert.addAction(UIAlertAction(title: "确定", style: .default, handler: confirm))
viewController.present(alert, animated: true)
} //在根视图控制器上弹出确认框
static func showConfirm(message: String, confirm: ((UIAlertAction)->Void)?) {
if let vc = UIApplication.shared.keyWindow?.rootViewController {
showConfirm(message: message, in: vc, confirm: confirm)
}
}
}

  

2.改变 标题颜色,按钮颜色,等等

https://blog.csdn.net/mo_xiao_mo/article/details/70308099

        let alert = UIAlertController(title: nil, message: "确定要退出登录吗?", preferredStyle: .actionSheet)

        /// 确认
let sureAction = UIAlertAction(title: "确认", style: UIAlertAction.Style.default) { [weak self](_) in
self?.requestLoginOut()
}
sureAction.setValue(UIColor.init(hexString: "#FF9E3E"), forKey: "_titleTextColor")
alert.addAction(sureAction) //取消操作
let cancleAction = UIAlertAction(title: "取 消", style: .cancel, handler: nil)
cancleAction.setValue(UIColor.init(hexString: "#424242"), forKey: "_titleTextColor")
alert.addAction(cancleAction)
self.present(alert, animated: true, completion: nil)

  

swift 警告框 - 自定义按钮颜色,图片的更多相关文章

  1. layui 弹出框改变按钮颜色样式 自定义皮肤

    1.在layer下新建文件夹和css 文件: 2.123.css body .layui-ext-yourskin .layui-layer-btn0{ border-color: #55ff83; ...

  2. ExtJS自定义按钮颜色

    直接使用CSS修饰. 这种方式操作,效果明显. 先为按钮新增一个CSS类 { xtype: 'button', //将边框.背景样式去掉 style: { border: 'none', backgr ...

  3. 【swift】用Xib实现自定义警告框(Alert)(安卓叫法:Dialog对话框)

    在写这篇博客前,先感谢两篇博客 [如何自定义的思路]:https://www.cnblogs.com/apprendre-10-28/p/10507794.html [如何绑定Xib并且使用]:htt ...

  4. iOS不得姐项目--登录模块的布局,设置文本框占位文字颜色,自定义内部控件竖直排列的按钮

    一.登录模块的布局 将一整部分切割成若干部分来完成,如图分成了三部分来完成 设置顶部状态栏为白色的方法 二.设置文本框占位文字颜色 <1>方法一与方法二实现原理是同一种,都是通过设置pla ...

  5. iOS开发——UI进阶篇(十八)核心动画小例子,转盘(裁剪图片、自定义按钮、旋转)图片折叠、音量震动条、倒影、粒子效果

    一.转盘(裁剪图片.自定义按钮.旋转) 1.裁剪图片 将一张大图片裁剪为多张 // CGImageCreateWithImageInRect:用来裁剪图片 // image:需要裁剪的图片 // re ...

  6. C#Winform使用扩展方法自定义富文本框(RichTextBox)字体颜色

    在利用C#开发Winform应用程序的时候,我们有可能使用RichTextBox来实现实时显示应用程序日志的功能,日志又分为:一般消息,警告提示 和错误等类别.为了更好地区分不同类型的日志,我们需要使 ...

  7. Android 学习笔记二 自定义按钮形状 颜色 点击渐变

    问题:自定义按钮的颜色 形状弧度  渐变效果 1.新建自定义属性button_login.xml (借鉴某大神) <?xml version="1.0" encoding=& ...

  8. 使用 JS 关闭警告框及监听自定义事件(amaze ui)

    使用 JS 关闭警告框及监听自定义事件(amaze ui) 一.总结 1.jquery匿名函数:第8行,jquery匿名函数,$(function(){});,有没有很简单,只是少了jquery的前面 ...

  9. 如何实现ZBrush 4R7中按钮颜色的自定义

          本文详细讲解在ZBrush® 4R7中如何改变按钮颜色. Zbrush默认的开关按钮颜色为橙黄色,若您不喜欢当前颜色,可以通过“Icolors”功能按钮下的各命令来更改界面开关颜色及透明度 ...

随机推荐

  1. 算法笔记 3.2 codeup1935 查找学生信息

    #include <stdio.h> #include <string.h> const int maxn = 1e3; struct student{ ]; ]; //!!! ...

  2. Linux服务器调教日常

    本文为Linux服务器调教日常,不保证正确. 1. sshd配置: https://www.cnblogs.com/byeyear/p/9289063.html 2. 禁止普通用户su 1. 编辑/e ...

  3. 将Long类型转为字母数字组合的jar包---Hashids

    在设计数据库时,我有时喜欢使用自增Id,而不是uuid,但是在面对终端用户时,直接暴露id不是一个好的行为. 经过查询,可以使用 Hashids 这个jar包将id转为类似YouTube的大小写字母和 ...

  4. centos6.5虚拟机无法访问外网解决办法

    安装了centos6.5虚拟机,使用的是桥接方式.把所有的配置已经写到/etc/sysconfig/network-scripts/ifcfg-eth0中后,发现内网可以ping通,外网却无法访问. ...

  5. iframe-父子-兄弟页面相互传值(jq和js两种方法)

    参考文章: http://blog.csdn.net/u013299635/article/details/78773207 http://www.cnblogs.com/xyicheng/archi ...

  6. 从Tomcat的处理web请求分析Java的内存模型

    Tomcat作为一个java应用,同样是有主线程和子线程的.主线使用while(true)的方式一直循环,等待客户端来连接.一个客户端来了之后,就从线程池中拿一个线程来处理请求,如果没有配置线程池,就 ...

  7. 02-Introspector内省设置单个属性

    package com.oa.test; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; ...

  8. ADB文件及文件夹操作

    1.创建文件夹: adb shell mkdir /data/local/tmp/local多级的一次只能创建一级adb shell mkdir /data/local/tmp/local/tmp 2 ...

  9. openstack网络

    OpenStack中neutron的2种ip.3种管理模式 Nova有固定IP和浮动IP的概念.固定IP被分发到创建的实例不再改变,浮动IP是一些可以和实例动态绑定和释放的IP地址. Nova支持3种 ...

  10. IIS下https配置及安全整改

    原文链接:https://www.cnblogs.com/JangoJing/p/6769759.html 1.https证书的分类 SSL证书没有所谓的"品质"和"等级 ...