diff --git a/ios/FluentUI/Table View/TableViewHeaderFooterView.swift b/ios/FluentUI/Table View/TableViewHeaderFooterView.swift index ea24f8532f..5884d817da 100644 --- a/ios/FluentUI/Table View/TableViewHeaderFooterView.swift +++ b/ios/FluentUI/Table View/TableViewHeaderFooterView.swift @@ -249,8 +249,6 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont /// - accessoryButtonTitle: Optional accessory button title string. /// - leadingView: An optional custom view that appears near the leading edge of the view. @objc open func setup(style: Style, title: String, accessoryButtonTitle: String = "", leadingView: UIView? = nil) { - resolvedTitleFont = tokenSet[.textFont].uiFont - resolvedTitleColor = tokenSet[.textColor].uiColor titleView.attributedText = NSAttributedString(string: " ") // to clear attributes titleView.text = title titleView.isSelectable = false @@ -275,10 +273,6 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont titleView.attributedText = attributedTitle titleView.isSelectable = true - let attributes = attributedTitle.attributes(at: 0, effectiveRange: nil) - resolvedTitleFont = attributes[NSAttributedString.Key.font] as? UIFont ?? tokenSet[.textFont].uiFont - resolvedTitleColor = attributes[NSAttributedString.Key.foregroundColor] as? UIColor ?? tokenSet[.textColor].uiColor - setup(style: style, accessoryButtonTitle: accessoryButtonTitle, leadingView: leadingView) } @@ -436,19 +430,18 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont private func updateTitleViewFont() { if let window = window { - titleView.font = resolvedTitleFont + let titleFont = tokenSet[.textFont].uiFont + titleView.font = titleFont // offset text container to center its content - if let resolvedTitleFont = resolvedTitleFont { - let scale = window.rootViewController?.view.contentScaleFactor ?? window.screen.scale - let offset = (floor((abs(resolvedTitleFont.leading) / 2) * scale) / scale) / 2 - titleView.textContainerInset.top = offset - titleView.textContainerInset.bottom = -offset - } + let scale = window.rootViewController?.view.contentScaleFactor ?? window.screen.scale + let offset = (floor((abs(titleFont.leading) / 2) * scale) / scale) / 2 + titleView.textContainerInset.top = offset + titleView.textContainerInset.bottom = -offset } } private func updateTitleAndBackgroundColors() { - titleView.textColor = resolvedTitleColor + titleView.textColor = tokenSet[.textColor].uiColor if tableViewCellStyle == .grouped { backgroundView?.backgroundColor = tokenSet[.backgroundColorGrouped].uiColor @@ -458,7 +451,7 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont backgroundView?.backgroundColor = .clear } - titleView.font = resolvedTitleFont + titleView.font = tokenSet[.textFont].uiFont titleView.linkColor = tokenSet[.linkTextColor].uiColor } @@ -494,9 +487,6 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, TokenizedCont @objc private func handleHeaderViewTapped() { onHeaderViewTapped?() } - - private var resolvedTitleFont: UIFont? - private var resolvedTitleColor: UIColor? } // MARK: - TableViewHeaderFooterView: UITextViewDelegate