简体   繁体   中英

Trouble setting UIView borderColor in iOS9.0

I am trying to set my UIView's layer.borderColor property to a custom UIColor like this:

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.

像这样:

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

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

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