![
屏幕快照 2016-10-25 下午7.39.54.png 屏幕快照 2016-10-25 下午7.41.04.png屏幕快照 2016-10-25 下午7.40.51.png ](https://img.haomeiwen.com/i2683945/1d67656a22fd70d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
//
// ViewController.swift
// 国际化Demo
//
// Created by 向银泉on 16/10/25.
// Copyright © 2016年 向银泉. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//根据系统的语言匹配对应的提示框
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
//创建弹出框
let alertVC = UIAlertController(title: NSLocalizedString("TITLE", comment: ""), message: NSLocalizedString("MESSAGE", comment: ""), preferredStyle: .Alert)
//确定按钮
let conformAction = UIAlertAction(title: NSLocalizedString("CONFORM", comment: ""), style: .Default, handler: nil)
//取消按钮
let cancelAction = UIAlertAction(title: NSLocalizedString("CANCEL", comment: ""), style: .Cancel, handler: nil)
alertVC.addAction(conformAction)
alertVC.addAction(cancelAction)
self.presentViewController(alertVC, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
"TITLE" = "title";
"MESSAGE" = "message";
"CONFORM" = "conform";
"CANCEL" = "cancel";
"TITLE" = "标题";
"MESSAGE" = "信息";
"CONFORM" = "确定";
"CANCEL" = "取消";
![屏幕快照 2016-10-25 下午7.40.10.png](https://img.haomeiwen.com/i2683945/0b580295de119f59.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
网友评论