Author: Chris Lattner
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 Combine | |
// The Request Method | |
enum HTTPMethod: String { | |
case get = "GET" | |
case post = "POST" | |
case put = "PUT" | |
case delete = "DELETE" | |
} |
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
// | |
// PagerView.swift | |
// | |
// Created by Majid Jabrayilov on 12/5/19. | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
struct PagerView<Content: View>: View { | |
let pageCount: Int |
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
# Turn on the simulator screen capture | |
xcrun simctl io booted recordVideo ~/simulator.mov | |
# Convert the iPhone 6s screen shot into a gif: | |
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif |
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 UIView { | |
func startShimmering(){ | |
let light = UIColor.white.cgColor | |
let alpha = UIColor.white.withAlphaComponent(0.7).cgColor | |
let gradient = CAGradientLayer() | |
gradient.colors = [alpha, light, alpha, alpha, light, alpha] | |
gradient.frame = CGRect(x: -self.bounds.size.width, y: 0, width: 3 * self.bounds.size.width, height: self.bounds.size.height) | |
gradient.startPoint = CGPoint(x: 0.0, y: 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
func _convertToBytes<T>(_ value: T, withCapacity capacity: Int) -> [UInt8] { | |
var mutableValue = value | |
return withUnsafePointer(to: &mutableValue) { | |
return $0.withMemoryRebound(to: UInt8.self, capacity: capacity) { | |
return Array(UnsafeBufferPointer(start: $0, count: capacity)) | |
} | |
} |
You can do it like this:
In your main view controller:
func showModal() {
let modalViewController = ModalViewController()
modalViewController.modalPresentationStyle = .OverCurrentContext
presentViewController(modalViewController, animated: true, 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
//: # Swift 3: Working with dates | |
import Foundation | |
let date = Date() | |
let myLocale = Locale(identifier: "bg_BG") | |
//: ### Setting an application-wide `TimeZone` | |
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case. | |
if let myTimezone = TimeZone(abbreviation: "EEST") { | |
print("\(myTimezone.identifier)") |
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
/// An Int representing a Jalaali year. | |
public typealias JalaaliYear = Int | |
/// An Int representing a Jalaali month (1-based). | |
public typealias JalaaliMonth = Int | |
/// An Int representing a Jalaali day. | |
public typealias JalaaliDay = Int | |
/// An Int representing a Gregorian year. |
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
package com.google.firebase.zerotoapp; | |
public class ChatMessage { | |
public String name; | |
public String message; | |
public ChatMessage() { | |
} | |
public ChatMessage(String name, String message) { |
NewerOlder