CALayer:仅在一侧添加边框

编程入门 行业动态 更新时间:2024-10-28 21:28:35
本文介绍了CALayer:仅在一侧添加边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以用这种方式为CALayer添加边框:

I can add a border to a CALayer in this way:

[webView.layer setBorderColor: [[UIColor colorWithRed:0.6 green:0.7 blue:0.2 alpha:1] CGColor]]; [webView.layer setBorderWidth: 2.75];

但是只能在一侧添加边框吗?我只需要底部的边框。或者我可以使用其他属性来达到此目的,例如frame,bounds,mask,...?

But is it possible to add a border only at one side? I only need a border at the bottom. Or can I reach this with other properties, e.g. frame, bounds, mask, ...?

感谢您的帮助!

@ Control-V

@Control-V

UIWebView *webView = [[UIWebView alloc] init]; CALayer *webViewLayer = webView.layer; // now you can do a lot of stuff like borders: [webViewLayer setBorderColor: [[UIColor greenColor] CGColor]]; [webViewLayer setBorderWidth: 2.75];

查看CALayer文档: developer.apple/documentation/quartzcore/calayer

Have a look at the CALayer documentation: developer.apple/documentation/quartzcore/calayer

看看这里: iosdevelopertips/cocoa/add-rounded-corners-and-border-to-uiwebview.html

推荐答案

我用这个做了一个右边框:

I made a right border using this:

leftScrollView.clipsToBounds = YES; CALayer *rightBorder = [CALayer layer]; rightBorder.borderColor = [UIColor darkGrayColor].CGColor; rightBorder.borderWidth = 1; rightBorder.frame = CGRectMake(-1, -1, CGRectGetWidth(leftScrollView.frame), CGRectGetHeight(leftScrollView.frame)+2); [leftScrollView.layer addSublayer:rightBorder];

更多推荐

CALayer:仅在一侧添加边框

本文发布于:2023-10-29 01:49:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538351.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在一   边框   CALayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!