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 SwiftUI | |
import WebKit | |
struct ContentView: View { | |
var body: some View { | |
Webview(url: URL(string: "https://google.com")!) | |
} | |
} | |
struct Webview: UIViewRepresentable { |
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
//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())! |
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
/* | |
* 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 |
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 monospaced = UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: .bold) | |
let fontMetrics = UIFontMetrics(forTextStyle: .body) | |
runtime.font = fontMetrics.scaledFont(for: monospaced) |
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
@interface NSImage (GIF) | |
- (BOOL)isGifImage; | |
- (BOOL)saveAnimatedGIFToFile:(NSString*)filepath; | |
@end | |
@implementation NSImage (GIF) | |
- (BOOL)isGifImage | |
{ |
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 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) | |
{ |
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 4.0.3 | |
import Foundation | |
extension NSRange: SurrogatePairAdjustable { | |
func adjusted(for pairs: [String.SurrogatePair]) -> NSRange { | |
if pairs.isEmpty { | |
return self | |
} | |
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
/* | |
* 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. | |
*/ |
NewerOlder