@@ -28,27 +28,57 @@ public struct Alert {
2828 }
2929 }
3030
31- public let title : String ?
32- public let titleFont : UIFont
33- public let message : String ?
34- public let messageFont : UIFont
31+ public enum Text {
32+ case string( String , UIFont )
33+ case attributedString( NSAttributedString )
34+ }
35+
36+ /// default font: `UIFont.systemFont(ofSize: 17, weight: .semibold)`
37+ public let title : Text ?
38+ /// default font: `UIFont.systemFont(ofSize: 13, weight: .regular)`
39+ public let message : Text ?
40+ /// Custom view to use instead of message or in addition to message.
3541 public let contentView : UIView ?
42+
3643 public let tintColor : UIColor ?
44+
3745 public let actions : [ Action ]
3846
39- public init ( title: String ? ,
40- titleFont: UIFont = UIFont . systemFont ( ofSize: 17 , weight: . semibold) ,
41- message: String ? ,
42- messageFont: UIFont = UIFont . systemFont ( ofSize: 13 , weight: . regular) ,
47+ public init ( title: Text ? ,
48+ message: Text ? ,
4349 contentView: UIView ? = nil ,
4450 tintColor: UIColor ? = nil ,
4551 actions: [ Action ] ) {
4652 self . title = title
47- self . titleFont = titleFont
4853 self . message = message
49- self . messageFont = messageFont
5054 self . contentView = contentView
5155 self . tintColor = tintColor
5256 self . actions = actions
5357 }
58+
59+ public init ( title: String ? ,
60+ titleFont: UIFont = UIFont . systemFont ( ofSize: 17 , weight: . semibold) ,
61+ message: String ? ,
62+ messageFont: UIFont = UIFont . systemFont ( ofSize: 13 , weight: . regular) ,
63+ contentView: UIView ? = nil ,
64+ tintColor: UIColor ? = nil ,
65+ actions: [ Action ] ) {
66+ self . init ( title: title. map { . string( $0, titleFont) } ,
67+ message: message. map { . string( $0, messageFont) } ,
68+ contentView: contentView,
69+ tintColor: tintColor,
70+ actions: actions)
71+ }
72+
73+ public init ( title: NSAttributedString ? ,
74+ message: NSAttributedString ? ,
75+ contentView: UIView ? = nil ,
76+ tintColor: UIColor ? = nil ,
77+ actions: [ Action ] ) {
78+ self . init ( title: title. map { . attributedString( $0) } ,
79+ message: message. map { . attributedString( $0) } ,
80+ contentView: contentView,
81+ tintColor: tintColor,
82+ actions: actions)
83+ }
5484}
0 commit comments