简体   繁体   English

在 iOS9.0 中设置 UIView borderColor 的问题

[英]Trouble setting UIView borderColor in iOS9.0

I am trying to set my UIView's layer.borderColor property to a custom UIColor like this:我正在尝试将我的 UIView 的layer.borderColor属性设置为这样的自定义 UIColor:

groupPageView.layer.borderColor = [UIColor colorWithRed:203.0 green:17.0 blue:17.0 alpha:1]

and it is not working.它不工作。 What is an easy way to accomplish this?有什么简单的方法可以实现这一目标? Xcode suggests that I cast it CGColorRef, but this does not work. Xcode 建议我将其转换为 CGColorRef,但这不起作用。

像这样:

groupPageView.layer.borderColor = [[UIColor colorWithRed:203.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1] CGColor]

1st Ensure you imported第一确保你进口

#import <UIKit/UIKit.h>

then add this 2 lines然后添加这2行

groupPageView.layer.borderColor = [UIColor colorWithRed:203.0 green:17.0 blue:17.0 alpha:1].CGColor
groupPageView.layer.borderWidth =2.0;//default width =0 ; so if not set you will not see border colour

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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