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
do { | |
let info = ProcessInfo.processInfo | |
let begin = info.systemUptime | |
// do something | |
let diff = (info.systemUptime - begin) | |
} |
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
var mediaAspectRatio: Double! // <- here will be set aspect ratio for video with url | |
func initAspectRatioOfVideo(with fileURL: URL) { | |
let resolution = resolutionForLocalVideo(url: fileURL) | |
guard let width = resolution?.width, let height = resolution?.height else { | |
return | |
} | |
mediaAspectRatio = Double(height / width) |
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 createProjectDirectoryPath(path:String) -> String | |
{ | |
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Constants.Notifications.appGroupIdentifier) | |
let logsPath = containerURL!.appendingPathComponent(path) | |
//print(logsPath.path); | |
do { | |
try FileManager.default.createDirectory(atPath: logsPath.path, withIntermediateDirectories: true, attributes: nil) | |
} catch let error as NSError { | |
print("Unable to create directory \(error.debugDescription)") |
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 activateProximitySensor(isOn: Bool) { | |
let device = UIDevice.current | |
device.isProximityMonitoringEnabled = isOn | |
if isOn { | |
NotificationCenter.default.addObserver(self, selector: #selector(proximityStateDidChange), name: UIDevice.proximityStateDidChangeNotification, object: device) | |
let session = AVAudioSession.sharedInstance() | |
do{ | |
try session.setCategory(.playAndRecord) | |
try session.setActive(true) | |
try session.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker) |
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
// | |
// RoundedImageTableViewCell.swift | |
// Mangosta | |
// | |
// Created by Denis Mikhaylovskiy on 25/07/2019. | |
// | |
import UIKit | |
class RoundedImageTableViewCell: UITableViewCell { |
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 Array{ | |
public mutating func appendDistinct<S>(contentsOf newElements: S, where condition:@escaping (Element, Element) -> Bool) where S : Sequence, Element == S.Element { | |
newElements.forEach { (item) in | |
if !(self.contains(where: { (selfItem) -> Bool in | |
return !condition(selfItem, item) | |
})) { | |
self.append(item) | |
} | |
} | |
} |
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
let transition: CATransition = CATransition() | |
transition.duration = 0.5 | |
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) | |
transition.type = CATransitionType.reveal | |
transition.subtype = CATransitionSubtype.fromLeft | |
self.view.window!.layer.add(transition, forKey: nil) | |
self.dismiss(animated: false, completion: nil) |
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 UISegmentedControl { | |
func removeBorder(){ | |
self.tintColor = UIColor.clear | |
self.backgroundColor = UIColor.clear | |
self.setTitleTextAttributes( [NSAttributedString.Key.foregroundColor : UIColor.stavkrugDarkBlue], for: .selected) | |
self.setTitleTextAttributes( [NSAttributedString.Key.foregroundColor : UIColor.gray], for: .normal) | |
} |
NewerOlder