// 进入后台
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
// 结束应用
DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
UIApplication.shared.perform(Selector(("terminateWithSuccess")))
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
struct ChineseTransliterator { | |
static func transliterate(text: String, sourceView: UIView) { | |
let textView = UITextView() | |
textView.isHidden = true | |
textView.text = text | |
textView.selectAll(nil) | |
sourceView.addSubview(textView) |
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if self.isBeingPresented || self.isMovingToParent {
//Perform an action that will only be done once
}
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DictionaryExtension.swift | |
// Haiyu | |
// zhao_zzq2012@163.com | |
// Created by zhaozzq@github on 2019/7/31. | |
// Copyright © 2019 Haiyu. All rights reserved. | |
// https://oleb.net/blog/2017/01/dictionary-key-paths/ | |
// https://swift.gg/2017/01/25/dictionary-key-paths/ | |
import Foundation |
- HTTP 形式:
git clone https://github.com/owner/git.git
- SSH 形式:
git clone git@github.com:owner/git.git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#仓库路径 | |
REPO_PATH=$1 | |
#文件的类型 | |
# OPEN_TYPE=$2 | |
LIST=`find "$REPO_PATH" -name "*.xcworkspace" | grep -v ".xcodeproj/project.xcworkspace"` | |
if [ -z "$LIST" ] ; then | |
LIST=`find "$REPO_PATH" -name "*.xcodeproj" | grep -v "Pods.xcodeproj"` | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) { | |
if animated { | |
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: { | |
let oldState: Bool = UIView.areAnimationsEnabled() | |
UIView.setAnimationsEnabled(false) | |
self.window!.rootViewController = rootViewController | |
UIView.setAnimationsEnabled(oldState) | |
}, completion: { (finished: Bool) -> () in | |
if completion { | |
completion!() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Duplicate Lines | |
# Shift + Option + Up Down Arrow Keys | |
# Move line up or down | |
# Alt / Option + Up Down Arrow Keys | |
# Write on multiple lines (without mouse) | |
# Shift + Option + Command + Up Down Arrow Keys | |
# Write on multiple lines (with mouse) |
WKWebViewConfiguration *configuration = [WKWebViewConfiguration new];
NSString *eruda = @"(function () { var script = document.createElement('script'); script.src='//cdn.jsdelivr.net/npm/eruda'; document.body.appendChild(script); script.onload = function () { eruda.init() } })();";
WKUserScript *script = [[WKUserScript alloc] initWithSource:eruda injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
[configuration.userContentController addUserScript:script];
_webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
or
NSString *jsPath = [[NSBundle mainBundle] pathForResource:@"vConsole" ofType:@"js"];
NewerOlder