Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
253cf0c1
authored
Nov 08, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加UIAlertController简便方法
parent
7fefbc80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
MRFramework/MRFramework/Extensions/UIKit/UIAlertController+util.swift
+65
-0
No files found.
MRFramework/MRFramework/Extensions/UIKit/UIAlertController+util.swift
0 → 100644
View file @
253cf0c1
//
// UIAlertController+util.swift
// MRFramework
//
// Created by Sarkizz on 2019/11/8.
// Copyright © 2019 sarkizz. All rights reserved.
//
import
Foundation
extension
UIAlertController
{
public
class
func
panel
(
title
:
String
?
=
nil
,
message
:
String
?,
buttonTitle
:
String
=
"确定"
,
completion
:
((
UIAlertAction
)
->
Void
)?
=
nil
)
->
UIAlertController
{
let
alert
=
UIAlertController
(
title
:
title
,
message
:
message
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
.
init
(
title
:
buttonTitle
,
style
:
.
default
,
handler
:
completion
))
return
alert
}
public
class
func
confirmPanel
(
title
:
String
?
=
nil
,
message
:
String
?,
confirmTitle
:
String
=
"确定"
,
cancelTitle
:
String
=
"取消"
,
completion
:
((
UIAlertAction
,
Bool
)
->
Void
)?
=
nil
)
->
UIAlertController
{
let
alert
=
UIAlertController
(
title
:
title
,
message
:
message
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
.
init
(
title
:
confirmTitle
,
style
:
.
default
,
handler
:
{
action
in
completion
?(
action
,
true
)
}))
alert
.
addAction
(
.
init
(
title
:
cancelTitle
,
style
:
.
cancel
,
handler
:
{
action
in
completion
?(
action
,
false
)
}))
return
alert
}
public
class
func
prompt
(
title
:
String
?
=
nil
,
message
:
String
?,
textFieldConfig
:
((
UITextField
)
->
Void
)?
=
nil
,
confirmTitle
:
String
=
"确定"
,
cancelTitle
:
String
=
"取消"
,
completion
:
((
UIAlertAction
,
String
?)
->
Void
)?
=
nil
)
->
UIAlertController
{
let
alert
=
UIAlertController
(
title
:
title
,
message
:
message
,
preferredStyle
:
.
alert
)
alert
.
addTextField
(
configurationHandler
:
textFieldConfig
)
alert
.
addAction
(
.
init
(
title
:
confirmTitle
,
style
:
.
default
,
handler
:
{
action
in
completion
?(
action
,
alert
.
textFields
?[
0
]
.
text
)
}))
alert
.
addAction
(
.
init
(
title
:
cancelTitle
,
style
:
.
cancel
))
return
alert
}
public
class
func
actionSheet
(
title
:
String
?
=
nil
,
message
:
String
?,
cancelTitle
:
String
=
"取消"
,
sheets
:
[
String
],
completion
:
((
UIAlertAction
,
Int
)
->
Void
)?
=
nil
)
->
UIAlertController
{
let
alert
=
UIAlertController
(
title
:
title
,
message
:
message
,
preferredStyle
:
.
actionSheet
)
sheets
.
enumerated
()
.
forEach
({
idx
,
title
in
alert
.
addAction
(
.
init
(
title
:
title
,
style
:
.
default
,
handler
:
{
(
action
)
in
completion
?(
action
,
idx
)
}))
})
alert
.
addAction
(
.
init
(
title
:
cancelTitle
,
style
:
.
cancel
))
return
alert
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment