2021: Reversort
2021: MoonsAndUmbrellas
2021: ReversortEngineering
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
// | |
// ViewController.swift | |
// CombineCombine | |
// | |
// Created by Woody Liu on 2021/8/16. | |
// | |
import UIKit | |
import Combine |
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
// | |
// OptionalNotified.swift | |
// | |
// Created by Woody Liu on 2021/7/24. | |
// | |
import Foundation | |
@propertyWrapper | |
public class OptionalNotified<Value: Equatable> { |
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 | |
@propertyWrapper | |
public class Notified<Value: Equatable> { | |
public let notificationName: Notification.Name | |
public var wrappedValue: Value { | |
didSet { | |
if oldValue != wrappedValue { |
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 | |
@propertyWrapper | |
public class Observed<T> { | |
private var _value: T { | |
didSet { | |
execute() | |
} | |
} | |
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 | |
@propertyWrapper | |
public class Observed<T> { | |
private var _value: T { | |
didSet { | |
execute() | |
} | |
} | |
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
/* 設定Label 文字漸層色 | |
有兩三種做法,這個作法是我最喜歡的,不需要考慮到 view 的生命週期。 | |
原理: 在label 繪製text之前。建立一個漸層色image,再將它轉成顏色給textColor | |
*/ | |
extension UIImage { |
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 UIColor { | |
class var mainXXX: UIColor { | |
let color = UIColor(XXX) | |
return color | |
} | |
static let main: UIColor = { |
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
/* | |
compressImgMid: 二分壓縮法,指定預期的 MB | |
imgWithNewSize: 更改 img 尺寸,可依照預期 imgView 的尺寸去縮放(一般縮到跟 imgView 預期最大即可) | |
*/ | |
extension UIImage { | |
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 NSMutableAttributedString { | |
func insertImage(image: UIImage?, tintColor: UIColor? = nil, bounds: CGRect = .zero, at: Int) { | |
let imageAttachment = NSTextAttachment() | |
if let tintColor = tintColor{ | |
// 搭配自己的UIImageExtension | |
imageAttachment.image = image?.tinted(color: tintColor) | |
} else { | |
imageAttachment.image = image | |
} |