Colors swift 3无法为标签指定正确的颜色';背景色

Colors swift 3无法为标签指定正确的颜色';背景色,colors,swift3,background,set,label,Colors,Swift3,Background,Set,Label,我正在尝试为标签的背景色指定颜色 我两方面都试过了 label1.layer.backgroundColor = UIColor(red: 255, green: 69, blue:0, alpha: 1).cgColor 及 但我在模拟器或设备上运行后,上面的两个标签显示错误的颜色,它显示黄色,有 正确的颜色是有机玻璃红色(255,69,0) 知道它是什么吗?你必须将它从255中分割出来,然后只有你才能得到RGB颜色。像下面这样做 label.layer.backgroundColor =

我正在尝试为标签的背景色指定颜色

我两方面都试过了

label1.layer.backgroundColor = UIColor(red: 255, green: 69, blue:0, alpha: 1).cgColor

但我在模拟器或设备上运行后,上面的两个标签显示错误的颜色,它显示黄色,有

正确的颜色是有机玻璃
红色(255,69,0)


知道它是什么吗?

你必须将它从
255
中分割出来,然后只有你才能得到
RGB
颜色。像下面这样做

label.layer.backgroundColor = UIColor(red: 255/255.0, green: 69/255.0, blue: 0/255.0, alpha: 1.0).cgColor
label.backgroundColor = UIColor.init(red: 255/255, green: 69/255, blue: 0/255, alpha: 1);
可能重复的
label.backgroundColor = UIColor.init(red: 255/255, green: 69/255, blue: 0/255, alpha: 1);