前幾天PM 提出一個需求,需求是A頁面點擊 Button A 會跳轉到 B 頁面, 而 B頁面有一個 Button B 點擊後會重新推出一個新的 A頁面。 所以依照這需求邏輯,當用戶不停的反覆 butoon A -> button B ,ViewController 會無限疊上去。 雖然最後了解這問題是故意設計的,不用處理,但是我還是稍微測試一下。
####測試
方案一、
override func draw(_ rect: CGRect) { | |
borderColor.setStroke() | |
borderColor.withAlphaComponent(backgroundOpacity).setFill() | |
let backgroundPath = UIBezierPath(roundedRect: bounds, cornerRadius: borderCornerRadius) | |
backgroundPath.fill() | |
let borderPath: UIBezierPath | |
let borderRect = bounds.insetBy(dx: borderWidth / 2, dy: borderWidth / 2) | |
if borderCornerSize == 0 { | |
borderPath = UIBezierPath(roundedRect: borderRect, cornerRadius: borderCornerRadius) | |
} else { |
{ | |
"timeZone": "Asia/Hong_Kong", | |
"dependencies": { | |
}, | |
"webapp": { | |
"access": "ANYONE_ANONYMOUS", | |
"executeAs": "USER_DEPLOYING" | |
}, | |
"exceptionLogging": "STACKDRIVER", | |
"oauthScopes": ["https://www.googleapis.com/auth/script.send_mail", "https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/script.scriptapp", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/userinfo.email"], |
// | |
// ViewController.swift | |
// Created by Woody on 2021/1/28. | |
/* | |
a simple example for removing the superimposed ViewController behind | |
*/ | |
import UIKit |
func deviceExifOrientationForBackCamera(_ deviceOrientation: UIDeviceOrientation = UIDevice.current.orientation) -> CGImagePropertyOrientation{ | |
switch deviceOrientation { | |
case .portrait: | |
return .right | |
case .landscapeLeft: | |
return .up | |
case .landscapeRight: | |
return .down | |
default: | |
return .right |
/* | |
Change UIAlert message textColor | |
*/ | |
extension UIAlertAction { | |
var titleTextColor: UIColor? { | |
get { | |
return self.value(forKey: "titleTextColor") as? UIColor | |
} set { |
// return UIImage.Orientation | |
private func imageOrientation(deviceOrientation: UIDeviceOrientation = UIDevice.current.orientation, | |
cameraPosition: AVCaptureDevice.Position = .front) -> UIImage.Orientation { | |
var deviceOrientation = deviceOrientation | |
if deviceOrientation == .faceDown || deviceOrientation == .faceUp || deviceOrientation == .unknown { | |
deviceOrientation = currectDeviceOrientation() | |
} |
/* | |
關閉UIView Anitmate小技巧。 | |
有時候設定一系列 View 互動動畫, 突然遇到一個需求,需要關閉特定動畫,但是其他動畫要繼續執行的需求時, | |
就會特別頭痛。 | |
比如內建 TableView delete/ insert 動畫 + 自定義的其他動畫時,處理起來會特別煩瑣。 | |
而我們可以用簡單的 UIView.performWithoutAnimation 配上 main Therad 處理這件事情 | |
*/ | |
UIView.performWithoutAnimation { | |
// 動畫被取消,但是自動判斷Difference 不會失效 |