This is pseudocode.
post
has been retrieved from the API.
Be sure to make substrings and other string operations by "multibyte" divisions.
//Orginal code from: https://gist.github.com/mecid/f8859ea4bdbd02cf5d440d58e936faec | |
//I just made some modification in appearnce, show monthly navigator and weekdays. | |
import SwiftUI | |
struct ContentView: View { | |
@Environment(\.calendar) var calendar | |
private var year: DateInterval { | |
calendar.dateInterval(of: .month, for: Date())! |
import SwiftUI | |
import WebKit | |
struct ContentView: View { | |
var body: some View { | |
Webview(url: URL(string: "https://google.com")!) | |
} | |
} | |
struct Webview: UIViewRepresentable { |
let monospaced = UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: .bold) | |
let fontMetrics = UIFontMetrics(forTextStyle: .body) | |
runtime.font = fontMetrics.scaledFont(for: monospaced) |
// Swift 4.0.3 | |
import Foundation | |
extension NSRange: SurrogatePairAdjustable { | |
func adjusted(for pairs: [String.SurrogatePair]) -> NSRange { | |
if pairs.isEmpty { | |
return self | |
} | |
extension CGFloat { | |
func radians() -> CGFloat { | |
let b = CGFloat(M_PI) * (self/180) | |
return b | |
} | |
} | |
extension UIBezierPath { | |
convenience init(circleSegmentCenter center:CGPoint, radius:CGFloat, startAngle:CGFloat, endAngle:CGFloat) | |
{ |
/* | |
* Clearfix for modern browsers | |
* 1. The space content is one way to avoid an Opera bug when the | |
* `contenteditable` attribute is included anywhere else in the document. | |
* Otherwise it causes space to appear at the top and bottom of elements | |
* that receive the `clearfix` class. | |
* 2. The use of `table` rather than `block` is only necessary if using | |
* `:before` to contain the top-margins of child elements. | |
*/ |
@interface NSImage (GIF) | |
- (BOOL)isGifImage; | |
- (BOOL)saveAnimatedGIFToFile:(NSString*)filepath; | |
@end | |
@implementation NSImage (GIF) | |
- (BOOL)isGifImage | |
{ |
/* | |
* CLAlert is a drop-in replacement for NSAlert | |
* | |
* A CLAlert is exactly the same as a NSAlert, except for the alert style behavior | |
* | |
* - An alert with the informational style (NSInformationalAlertStyle) will always display a "Note icon" (kAlertNoteIcon) | |
* - An alert with the warning style (NSWarningAlertStyle) will always display a "Caution icon" (kAlertCautionIcon) | |
* - An alert with the critical style (NSCriticalAlertStyle) will always display a "Stop icon" (kAlertStopIcon) | |
* | |
* Tested on Mac OS X 10.5.8, 10.6.1 and 10.11.5 |