本文介绍了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:仅在一侧添加边框
发布评论