iOS swift: добавить керн в текст панели вкладок - PullRequest
0 голосов
/ 04 июня 2018

Я не могу добавить пространство керн в атрибутивный текст панели вкладок.Рассматриваемый UITabBar - это настраиваемая вкладка, код которой вы можете найти ниже.

Я использую словарь "приписанного ключа" для добавления атрибутов в заголовок элементов, но у меня проблема с ядромпробел.

class ProfileTabBar: UITabBar {

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.setStyle()
}

required override init(frame: CGRect) {
    super.init(frame: frame)
    self.setStyle()
}

func setStyle() {
    self.tintColor = Style.shared.primary1

    // Disable the default border
    self.layer.borderWidth = 0.0
    self.clipsToBounds = true

    // Create a new bottom border
    let bottomLine = CALayer()

    let screenWidth = UIScreen.main.bounds.width
    //let viewForFrame = self.superview ?? self
    //let screenWidth = viewForFrame.bounds.width

    bottomLine.frame = CGRect(x: 0.0, y: self.frame.height - 1, width: screenWidth, height: 2.0)
    bottomLine.backgroundColor = UIColor(red: 235.0/255, green: 235.0/255, blue: 235.0/255, alpha: 1.0).cgColor
    self.layer.addSublayer(bottomLine)

    // Get the size of a single item
    let markerSize = CGSize(width: screenWidth/CGFloat(self.items!.count), height: self.frame.height)

    // Create the selection indicator
    self.selectionIndicatorImage = UIImage().createSelectionIndicator(color: self.tintColor, size: markerSize , lineWidth: 3.0)


    // Customizing the items
    if let items = self.items {
        for item in items {

            item.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -15)

            let attributes: [NSAttributedStringKey : Any] = [
                NSAttributedStringKey.font: UIFont(name: Style.shared.fontBold.fontName, size: 14) as Any,
                NSAttributedStringKey.kern: NSNumber(value: 1.0)
            ]
            item.setTitleTextAttributes(attributes, for: .normal)

        }
    }

}

Все атрибуты работают, кроме ядра.Что я делаю не так?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...