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
// iOS 15 and above | |
func presentSecondViewController() { | |
guard let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as? SecondViewController else { return } | |
secondViewController.providesPresentationContextTransitionStyle = true | |
secondViewController.definesPresentationContext = true | |
secondViewController.modalPresentationStyle = .formSheet // The presentation style for modal view controllers | |
secondViewController.isModalInPresentation = true // Cancels dismiss the viewController by swiping down | |
secondViewController.modalTransitionStyle = .coverVertical // The transition style to use when presenting the view controller | |
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
// App information such as app name, app version, etc. | |
// AppInfo.swift | |
// Created by Evgeny Konkin on 23.02.2021. | |
// | |
import Foundation | |
struct AppInfo { | |
private static func dictionary(key string: String) -> String? { |
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
/* | |
UserDefaults (NSUserDefaults) is a go-to database for saving users' preferences over application behavior, | |
e.g., font size, sound disable/enable. So, most of the time, you want each of them to have a default value. | |
*/ | |
// Basic approach | |
let userDefaults = UserDefaults.standard | |
// 1 |
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
extension UIFont { | |
/// San Francisco System Font | |
/// - Parameters: | |
/// - fontSize: Font size | |
/// - weight: Font weight (Optional, by default: weight is regular) | |
/// - design: Font design: default, rounded, monospaced, serif (Optional, by default: design is default) | |
/// - Returns: System font of your size, weight and design | |
static func systemFont(ofSize fontSize: CGFloat, weight: UIFont.Weight = .regular, design: UIFontDescriptor.SystemDesign = .default) -> UIFont { | |
// Will be SF Compact or standard SF in case of failure. | |
if let descriptor = UIFont.systemFont(ofSize: fontSize, weight: weight).fontDescriptor.withDesign(design) { |
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
// MARK: Play sound function | |
func playSound(fileName: String) { | |
guard let url = Bundle.main.url(forResource: fileName, withExtension: "mp3") else { | |
print("the sound file isn't founded") | |
return | |
} | |
do { | |
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default) | |
try AVAudioSession.sharedInstance().setActive(true) |
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
<!DOCTYPE html> | |
<head> | |
<style> | |
ol { | |
list-style-type: none; | |
counter-reset: item; | |
} | |
li:before { | |
content: counters(item, '.', decimal) '. '; | |
counter-increment: item; |
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
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0-modified | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, |
NewerOlder