简体   繁体   中英

change border color on custom color

I v got UITextView, and I want to set it a new custom color like this

    var instaColor = UIColor(red: 51, green: 92, blue: 131, alpha: 1).CGColor

    textView.layer.borderWidth = 1
    textView.layer.cornerRadius = 20
    textView.layer.borderColor = instaColor

but its color is white or not appear at all, whats with this? this color should be dark blue + green

UIColor requires the color values to be between 0 and 1 so you should change it to:

var instaColor = UIColor(red: 51/255, green: 92/255, blue: 131/255, alpha: 1).CGColor

In the above you are dividing each value by 255 to get the color value to between 0 and 1.

I think your code should work after you do that.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM