Fix large content viewer for DoubleTitleLabelNavigationBarTitleView
This commit is contained in:
parent
2b2a879905
commit
eef98ea70b
|
@ -53,18 +53,22 @@ extension DoubleTitleLabelNavigationBarTitleView {
|
||||||
containerView.addArrangedSubview(subtitleLabel)
|
containerView.addArrangedSubview(subtitleLabel)
|
||||||
|
|
||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
|
showsLargeContentViewer = true
|
||||||
|
addInteraction(UILargeContentViewerInteraction())
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(title: String, subtitle: String?) {
|
func update(title: String, subtitle: String?) {
|
||||||
titleLabel.configure(content: PlaintextMetaContent(string: title))
|
titleLabel.configure(content: PlaintextMetaContent(string: title))
|
||||||
update(subtitle: subtitle)
|
update(subtitle: subtitle)
|
||||||
accessibilityLabel = subtitle.map { "\(title), \($0)" } ?? title
|
accessibilityLabel = subtitle.map { "\(title), \($0)" } ?? title
|
||||||
|
largeContentTitle = accessibilityLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(titleMetaContent: MetaContent, subtitle: String?) {
|
func update(titleMetaContent: MetaContent, subtitle: String?) {
|
||||||
titleLabel.configure(content: titleMetaContent)
|
titleLabel.configure(content: titleMetaContent)
|
||||||
update(subtitle: subtitle)
|
update(subtitle: subtitle)
|
||||||
accessibilityLabel = subtitle.map { "\(titleMetaContent.string), \($0)" } ?? titleMetaContent.string
|
accessibilityLabel = subtitle.map { "\(titleLabel.backedString), \($0)" } ?? titleLabel.backedString
|
||||||
|
largeContentTitle = accessibilityLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(subtitle: String?) {
|
func update(subtitle: String?) {
|
||||||
|
|
|
@ -152,4 +152,18 @@ extension MetaLabel {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var backedString: String {
|
||||||
|
let string = textStorage.string
|
||||||
|
let nsString = NSMutableString(string: string)
|
||||||
|
textStorage.enumerateAttribute(
|
||||||
|
.attachment,
|
||||||
|
in: NSRange(location: 0, length: textStorage.length),
|
||||||
|
options: [.reverse])
|
||||||
|
{ value, range, _ in
|
||||||
|
guard let attachment = value as? MetaAttachment else { return }
|
||||||
|
nsString.replaceCharacters(in: range, with: attachment.string)
|
||||||
|
}
|
||||||
|
return nsString as String
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue