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
import UIKit | |
class NSLayoutManagerViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
// 超長的文字 | |
let longText = """ | |
余憶童稚時,能張目對日,明察秋毫。見藐小微物,必細察其紋理,故時有物外之趣。 |
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
import UIKit | |
import CoreText | |
class CoreTextViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
// 超長的文字 |
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
func mapView(_ mapView: MKMapView, didChange mode: MKUserTrackingMode, animated: Bool) { | |
let userCoordinate = mapView.userLocation.coordinate | |
let rect = MKMapRect( | |
origin: .init(userCoordinate), | |
size: .init( | |
width: 12000.001100748777 / 2, | |
height: 21504.00197261572 / 4 * 3 | |
) | |
) | |
let edgePadding = UIEdgeInsets( |
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
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-122299963-1"> | |
</script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'UA-122299963-1'); | |
</script> |
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
//Case 1 | |
//Only 1 file, file name is String+extension.swift | |
extension String { | |
func doA() {} | |
func doB() {} | |
} | |
//Case 2 |
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
// | |
// PropertyWrapper+DidSet.swift | |
// | |
// | |
// Created by Hanyu on 2020/6/2. | |
// | |
import Foundation | |
@propertyWrapper |
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 String { | |
static var htmlString: String { | |
let content = NSLocalizedString("了解更多關於 <a href='/'>隱私權</a> 及 <a href='/'>使用條款</a>", comment: "") | |
return #""" | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> | |
<style type="text/css"> |
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
import Foundation | |
//Orignal code | |
class APIClient { | |
class let shared = APIClient() | |
func doA() { | |
//Do A | |
} |
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
import XCTest | |
import Moya | |
extension XCTestCase { | |
func expectation(description: String, timeout seconds: TimeInterval, handler: (@escaping () -> Void) -> Void) { | |
let expectation = XCTestExpectation(description: description) | |
handler({ | |
expectation.fulfill() | |
}) |
NewerOlder