gpt4 book ai didi

ios - iOS 应用程序警报和通知中的表情符号 - Xcode/Swift

转载 作者:搜寻专家 更新时间:2023-10-31 08:18:01 24 4
gpt4 key购买 nike

我正在尝试在 Xcode 中向警报添加表情符号,但无法弄清楚,非常感谢任何帮助!\xF0\x9F\x98\xB3

代码:

if ((self.liveStreamTitle.text?.characters.count) == 0)
{

let alertView = UIAlertController.init(title: "Forgot something?", message: "Video Title is empty EMOJIHERE", preferredStyle: UIAlertControllerStyle.Alert)
alertView.addAction(UIAlertAction.init(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertView, animated: true, completion: {

})

return;

}

最佳答案

其实你可以直接添加它们。

@IBAction func pressed(sender: AnyObject) {

let actionSheetController: UIAlertController = UIAlertController(title: "Are you sure?", message: "", preferredStyle: .Alert)
let cancelAction: UIAlertAction = UIAlertAction(title: "😡 NO", style: .Cancel) { action -> Void in
//Do your task
}
actionSheetController.addAction(cancelAction)
let nextAction: UIAlertAction = UIAlertAction(title: "😍 YES", style: .Default) { action -> Void in
//Do your task
}
actionSheetController.addAction(nextAction)
self.presentViewController(actionSheetController, animated: true, completion: nil)

}

enter image description here

您也可以使用 Unicode 执行此操作

let cancelAction: UIAlertAction = UIAlertAction(title: "\u{1F425}", style: .Cancel) { action -> Void in
let nextAction: UIAlertAction = UIAlertAction(title: "\u{1F426}", style: .Default) { action -> Void in

enter image description here

或者这个使用 Unicode

let cancelAction: UIAlertAction = UIAlertAction(title: "\u{1F425} YES", style: .Cancel) { action -> Void in
let nextAction: UIAlertAction = UIAlertAction(title: "\u{1F426} NO", style: .Default) { action -> Void in

enter image description here

Emoji Unicode Chart

关于ios - iOS 应用程序警报和通知中的表情符号 - Xcode/Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38340493/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com