This file contains hidden or 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 Foundation | |
| extension String { | |
| /// UTF16位置を文字位置に | |
| func convertPosition(utf16pos: Int) -> Index? { | |
| // UTF16のIndexを取得 | |
| let utf16view = self.utf16 | |
| let utf16index = utf16view.index(utf16view.startIndex, offsetBy: utf16pos) | |
| return utf16index.samePosition(in: self) |
This file contains hidden or 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
| class ViewController: UIViewController, GADInterstitialDelegate { | |
| var interstitial: GADInterstitial! | |
| ... | |
| /// ビューの表示アニメーションを強制変更 | |
| override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { | |
| viewControllerToPresent.modalTransitionStyle = .crossDissolve |
This file contains hidden or 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 | |
| extension UIImage { | |
| /// alphaチャネルだけ取得する | |
| /// fillColor: 塗りつぶす色 | |
| /// invert: alphaを反転するか | |
| func getAlphaImage(fillColor: UIColor = UIColor.white, invert: Bool = false) -> UIImage? { | |
| UIGraphicsBeginImageContextWithOptions(size, false, 0) | |
| // 塗りつぶし |
This file contains hidden or 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 WebKit | |
| /// adding "console.log" support | |
| extension WKWebView: WKScriptMessageHandler { | |
| /// enabling console.log | |
| public func enableConsoleLog() { | |
| // set message handler | |
| configuration.userContentController.add(self, name: "logging") |