【问题标题】:Swift how can I partially change UILabel's colour斯威夫特我怎么能部分改变UILabel的颜色
【发布时间】:2021-02-16 07:36:54
【问题描述】:

我正在我的应用导航栏上设计一个选项栏,我想实现与音乐应用相同的UI,正如你所看到的,当滑块滑动时,UILabel正在部分改变它的颜色,如何这会存档吗?我应该在 CALayer 上工作吗?

这是我到目前为止所做的,只是不正确

UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: {
        
            self.optionBarSlider.frame = self.selectedButton.frame
        }) { _ in
            self.selectedButton.setTitleColor(.black, for: .normal)
        } 

【问题讨论】:

    标签: swift uilabel calayer


    【解决方案1】:

    您可以通过设置attributedText 来更改所需部分的颜色

    How do you set an Attributed Title Color for State in Swift

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-21
      • 2017-07-22
      • 2017-03-24
      • 1970-01-01
      相关资源
      最近更新 更多