我在我的快捷应用中使用Material Desing Components library for iOS。
我需要展示一个带有两个动作( MDCAlertAction )的Alert Dialog,这两个动作将具有不同的强调值( MDCActionEmphasis )。
问题是,有没有办法为每个动作设置不同的配色方案?
这是我想在代码中执行的操作:
// example alert with two actions with different emphasis levels
let alert = MDCAlertController(title: "Test alert", message: "Here are some button types")
let criticalAction = MDCAlertAction(title: "Confirm", emphasis: .high, handler: nil)
let otherAction = MDCAlertAction(title: "Wait", emphasis: .medium, handler: nil)
alert.addAction(criticalAction)
alert.addAction(otherAction)
// scheme i'd like to apply to criticalAction
let redTheme = MDCContainerScheme()
redTheme.colorScheme.primaryColor = .red
// scheme i'd like to apply to otherAction
let blueTheme = MDCContainerSCheme()
blueTheme.colorScheme.primaryColor = .blue
// What i've read in documentation
// this will set theme for both of actions
alert.applyTheme(withScheme: redTheme)
// What i'd like to achieve in some way
criticalAction. setTheme(redTheme)
otherAction. setTheme(blueTheme)
如果能找到一种样式设计这些动作的方法,我将不胜感激。预先感谢!