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
// | |
// anyCodabelValue.swift | |
// Sajjad Sarkoobi | |
// | |
// Created by Sajjad Sarkoobi on 6/8/20. | |
// Copyright © 2020 Sajjad Sarkoobi. All rights reserved. | |
// Email: [email protected] | |
import Foundation |
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 resizedImage(for size: CGSize) -> UIImage? { | |
let image = self.cgImage | |
let context = CGContext(data: nil, | |
width: Int(size.width), | |
height: Int(size.height), | |
bitsPerComponent: image!.bitsPerComponent, | |
bytesPerRow: Int(size.width), | |
space: image?.colorSpace ?? CGColorSpace(name: CGColorSpace.sRGB)!, | |
bitmapInfo: image!.bitmapInfo.rawValue) | |
context?.interpolationQuality = .high |
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 WebKit | |
class NativeWebViewController: UIViewController { | |
let viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);" | |
let disableSelectionScriptString = "document.documentElement.style.webkitUserSelect='none';" | |
let disableCalloutScriptString = "document.documentElement.style.webkitTouchCallout='none';" | |
override func viewDidLoad() { | |
// 1 - Make user scripts for injection |
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
extension UITapGestureRecognizer { | |
func didTapAttributedTextInLabel(label: UILabel, targetText: String) -> Bool { | |
guard let attributedString = label.attributedText, let lblText = label.text else { return false } | |
let targetRange = (lblText as NSString).range(of: targetText) | |
//IMPORTANT label correct font for NSTextStorage needed | |
let mutableAttribString = NSMutableAttributedString(attributedString: attributedString) | |
mutableAttribString.addAttributes( | |
[NSAttributedString.Key.font: label.font ?? UIFont.smallSystemFontSize], | |
range: NSRange(location: 0, length: attributedString.length) |
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
extension UIImage { | |
func image(withRotation radians: CGFloat) -> UIImage { | |
let cgImage = self.cgImage! | |
let LARGEST_SIZE = CGFloat(max(self.size.width, self.size.height)) | |
let context = CGContext.init(data: nil, width:Int(LARGEST_SIZE), height:Int(LARGEST_SIZE), bitsPerComponent: cgImage.bitsPerComponent, bytesPerRow: 0, space: cgImage.colorSpace!, bitmapInfo: cgImage.bitmapInfo.rawValue)! | |
var drawRect = CGRect.zero | |
drawRect.size = self.size | |
let drawOrigin = CGPoint(x: (LARGEST_SIZE - self.size.width) * 0.5,y: (LARGEST_SIZE - self.size.height) * 0.5) |
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
/* | |
* Example implementation | |
*/ | |
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { | |
println("Launched with URL: \(url.absoluteString)") | |
let userDict = self.urlPathToDictionary(url.absoluteString) | |
//Do something with the information in userDict |
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
# Building FAT librares for XCode 10 | |
set -e | |
# If we're already inside this script then die | |
if [ -n "$MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then | |
exit 0 | |
fi | |
export MULTIPLATFORM_BUILD_IN_PROGRESS=1 |
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
// | |
// DataProviding.swift | |
// GenericsDataSource | |
// | |
// Created by Frank Courville on 2019-05-09. | |
// Copyright © 2019 iOS Coach Frank. All rights reserved. | |
// | |
import UIKit |
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 CoreData | |
import UIKit | |
struct Photo {} | |
class PhotoDetailViewController: UIViewController { | |
var photo: Photo! | |
var context: NSManagedObjectContext! | |
} |
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 Foundation | |
import XCTest | |
////////////////////////////////////////////////////////////////////// | |
// Preferences | |
protocol UserDefaults { | |
func stringForKey(key: String) -> String | |
} |
NewerOlder