- http使用
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- log去除AQDefaultDevice (173): skipping input stream 0 0 0x0
选择 Product -->Scheme-->Edit Scheme; 选择 Arguments; 在Environment Variables添加一个环境变量 OS_ACTIVITY_MODE 设置值为 disable
ok - status的颜色设置
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
顶部状态栏文字变白色
UIApplication.shared.setStatusBarStyle(UIStatusBarStyle.lightContent, animated: false)
状态栏背景颜色:self.navigationController?.navigationBar.barTintColor
隐藏状态栏:info.plist下面加
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
4 // 手机振动一下
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
5 // 返回 颜色
self.navigationController?.navigationBar.tintColor = UIColor.white
6 返回文字省略
// 设置返回文字,不然太长了
let item = UIBarButtonItem(title: "返回", style: .plain, target: self, action: nil)
self.navigationItem.backBarButtonItem = item;
7 键盘上面添加一个收起键盘的按钮,比如说:完成,当然也可以添加上一项、下一项的按钮:点击完成时,只是负责键盘的收起:
func AddToolBar() -> UIToolbar {
let toolBar:UIToolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 35))
toolBar.backgroundColor = UIColor.gray
let spaceBtn = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let barBtn = UIBarButtonItem(title: "完成", style: .plain, target: self, action: #selector(doneNum))
toolBar.items = [spaceBtn, barBtn]
return toolBar
}
func doneNum() {
self.view.endEditing(false)
}
// 加上
//outPlTextField.inputAccessoryView = AddToolBar()
8 字符串替换
var s = data.replacingOccurrences(of: "{\"code\":\"0\",\"data\":[", with: "[")
s = s.replacingOccurrences(of: "}]}", with: "}]")
9 大小
上44+20,底部导航44,下图片25/50/75,上按钮
10 时间显示 2017-10-15 16:53:02
let ctime = Date()
let dformatter = DateFormatter()
dformatter.dateFormat = "【YYYY-MM-dd hh:mm:ss】"
dformatter.timeZone = NSTimeZone.system
let strTime = dformatter.string(from: ctime)
print(strTime)
11 更新本地仓库pod install --repo-update
, pod update
12 拷贝到剪切板
let paste = UIPasteboard.general
paste.string = str
13 点击任意位置,取消键盘
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(false)
}