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 UITapGestureRecognizer { | |
func didTapAttributedTextInLabel(label: UILabel, targetText: String) -> Bool { | |
guard let attributedString = label.attributedText, let lblText = label.text else { return false } | |
let targetRange = (lblText as NSString).range(of: targetText) | |
//IMPORTANT label correct font for NSTextStorage needed | |
let mutableAttribString = NSMutableAttributedString(attributedString: attributedString) | |
mutableAttribString.addAttributes( | |
[NSAttributedString.Key.font: label.font ?? UIFont.smallSystemFontSize], | |
range: NSRange(location: 0, length: attributedString.length) |
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
// Private supporting types | |
private struct AnyCodingKey: CodingKey { | |
var stringValue: String | |
var intValue: Int? | |
init(_ string: String) { | |
stringValue = string | |
} | |
init?(stringValue: String) { |
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
// 1. First of all, you need to make sure “Device Orientation” only on ‘Portrait’ mode. | |
//2. Add these two functions to AppDelegate, which helps you deal with embed in nav bar/tab bar situation mentioned above: | |
protocol Rotatable: AnyObject { | |
func resetToPortrait() | |
} | |
extension Rotatable where Self: UIViewController { | |
func resetToPortrait() { |