I'm trying to add an emoji to an alert in Xcode but can't figure it out, any help is greatly appreciated! \xF0\x9F\x98\xB3
Code:
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;
}
Actually you can just add them directly.
@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)
}
You can also do this using 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
Or this using 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With