简体   繁体   中英

How do I use a different color for different border edges of a CALayer?

In order to draw a border around my UIView, I use the following code :

[_rectView.layer setBorderColor:[[UIColor blackColor] CGColor]];
[_rectView.layer setBorderWidth:1.0];

For one view, I would like to render only the right edge of my layer in black, the other 3 edges should be transparent.

How could I do that ?

You can use the CALayer's delegate to draw anything, including a black line on the right edge. I have had success with custom layer drawing in -drawLayer:inContext: .

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