<commit_before>//
//  UIBarButtonItem+TitleTextAttributeStates.swift
//  PinpointKit
//
//  Created by <NAME> on 5/4/18.
//

import UIKit

/// Extends `UIBarButtonItem` to fix an issue with title text attribute propagation.
extension UIBarButtonItem {
    
    /// Sets the specified title text attributes for `.normal`, `.highlighted`, `.disabled`, and `.selected` control states.
    ///
    /// - Parameter titleTextAttributes: A dictionary containing key-value pairs for text attributes.
    /// - Note: It should be enough to specify `.normal` and have the attributes propagate, but a bug (radar: 35221407) was introduced in iOS 11 which broke this functionality.
    func setTitleTextAttributesForAllStates(_ titleTextAttributes: [NSAttributedStringKey: Any]?) {
        
        // Note: Specifying them all in one option set also does not work correctly. The `.normal` state will revert to default text attributes.
        setTitleTextAttributes(titleTextAttributes, for: [.normal])
        setTitleTextAttributes(titleTextAttributes, for: [.highlighted])
        setTitleTextAttributes(titleTextAttributes, for: [.disabled])
        setTitleTextAttributes(titleTextAttributes, for: [.selected])
    }
}<commit_msg>.selected → .focused<commit_after>//
//  UIBarButtonItem+TitleTextAttributeStates.swift
//  PinpointKit
//
//  Created by <NAME> on 5/4/18.
//

import UIKit

/// Extends `UIBarButtonItem` to fix an issue with title text attribute propagation.
extension UIBarButtonItem {
    
    /// Sets the specified title text attributes for `.normal`, `.highlighted`, `.disabled`, and `.focused` control states.
    ///
    /// - Parameter titleTextAttributes: A dictionary containing key-value pairs for text attributes.
    /// - Note: It should be enough to specify `.normal` and have the attributes propagate, but a bug (radar: 35221407) was introduced in iOS 11 which broke this functionality.
    func setTitleTextAttributesForAllStates(_ titleTextAttributes: [NSAttributedStringKey: Any]?) {
        
        // Note: Specifying them all in one option set also does not work correctly. The `.normal` state will revert to default text attributes.
        setTitleTextAttributes(titleTextAttributes, for: [.normal])
        setTitleTextAttributes(titleTextAttributes, for: [.highlighted])
        setTitleTextAttributes(titleTextAttributes, for: [.disabled])
        setTitleTextAttributes(titleTextAttributes, for: [.focused])
    }
}
{'fraction_non_alphanumeric': 0.0966952264381885, 'fraction_numerical': 0.01142390860873113, 'mean_word_length': 3.600375234521576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3024444', 'n_tokens_mistral': 669, 'n_tokens_neox': 640, 'n_words': 228}