Skip to content

Commit b093aaf

Browse files
author
Eric Wu
committed
增加actionSheet
1 parent 96f1813 commit b093aaf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

CRBoostSwift/Classes/CRMath.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,24 @@ public func CRPresentAlert(title: String?, msg: String, handler: AlertAction? =
380380
return alert
381381
}
382382

383+
@discardableResult
384+
public func CRPresentActionSheet(title: String? = nil, msg: String? = nil, handler: AlertAction? = nil, canel: String = "取消", actions: String...) -> UIAlertController {
385+
let alert = UIAlertController(title: title, message: msg, preferredStyle: .actionSheet)
386+
if !canel.isEmpty {
387+
let alertAction = UIAlertAction(title: canel, style: .cancel, handler: handler)
388+
alert.addAction(alertAction)
389+
}
390+
actions.forEach { item in
391+
if !item.isEmpty {
392+
let alertAction = UIAlertAction(title: item, style: .default, handler: handler)
393+
alert.addAction(alertAction)
394+
}
395+
}
396+
CRTopViewController()?.present(alert, animated: true, completion: nil)
397+
return alert
398+
}
399+
400+
383401
@discardableResult
384402
public func CRPresentAlert(title: String?, msg: String) -> UIAlertController {
385403
return CRPresentAlert(title: title, msg: msg, handler: nil, canel: NSLocalizedString("OK", comment: ""))

0 commit comments

Comments
 (0)