简体   繁体   中英

How to change color of the custom side of border?

I want to make visible just bottom border of TextView. How can I do it?

Can I make visible just bottom side of the textView or there are another method?

You can add layer for your aim, but I'm not sure that is right way.

+ (void)addBottomBorderToView: (UIView * ) view WithColor:(UIColor *)color andWidth:(CGFloat) borderWidth
{
    CALayer * bottomBorder = [CALayer layer];
    bottomBorder.borderColor = color.CGColor;
    bottomBorder.borderWidth = borderWidth;
    bottomBorder.frame = CGRectMake(0, view.frame.size.height - borderWidth, view.frame.size.width, borderWidth);
    [view.layer addSublayer:bottomBorder];
}

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