【问题标题】:Button border color - Objective C - Swift按钮边框颜色 - Objective C - Swift
【发布时间】:2016-03-15 18:33:18
【问题描述】:

我想将我的边框颜色更改为特定的十六进制颜色(#21CE99),你们能帮帮我吗?

我已经知道如何将其更改为基本颜色,例如:

_button.layer.borderColor = [UIColor greenColor].CGColor;

但我只需要这种颜色。

谢谢。

回答

How to set the custome border color of UIView programmatically in swift

【问题讨论】:

    标签: objective-c xcode swift layout


    【解决方案1】:
    _button.layer.borderColor = [UIColor colorWithRed:33.0 / 255.0 green:206.0 / 255.0 blue:153.0 / 255.0 alpha:1.0].CGColor;
    

    【讨论】:

      【解决方案2】:

      更简单

      _button.layer.borderColor = [UIColor colorWithRed:0x21 / 255.0 green:0xce / 255.0 blue:0x99 / 255.0 alpha:1.0].CGColor;
      

      【讨论】:

        【解决方案3】:

        使用 SWIFT 4 的人的正确答案是:

        _button.layer.borderColor = UIColor(red: 33/255, green: 206/255, blue: 153/255, alpha: 1.0).cgColor
        

        内置 UIColors 预设或您自己的颜色:

        _button.layer.borderColor = UIColor.blue.cgColor
        

        【讨论】:

          猜你喜欢
          • 2016-02-24
          • 1970-01-01
          • 2018-11-03
          • 2013-10-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多