iOS 应用提醒和通知中的表情符号 - Xcode/Swift

Emoji in iOS app Alerts and Notifications - Xcode/Swift

我正在尝试向 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)

}

您也可以使用 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

或者使用 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

Emoji Unicode Chart