Mas*_*son 4 objective-c calayer uitextview ios
我有一个UITextView,我在其图层上设置边框宽度,边框颜色和角半径属性,外部看起来很棒.但是,边框的内部没有像外部一样的圆角,看起来很有趣.有没有办法绕过边界的内角?
编辑:这是我在initWithFrame:方法中使用的代码:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = UIColorFromRGB(0xdedede);
self.layer.cornerRadius = kTextFieldCornerRadius;
self.layer.borderColor = UIColorFromRGB(0xD4974C).CGColor;
self.layer.borderWidth = 3.0f;
self.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:12.0f];
[self setClipsToBounds:YES];
[self.layer setMasksToBounds:YES];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
这是现在的截图: 
请注意,外角是按预期圆角,但边框的内角是尖的而不是圆的.这就是我想要解决的问题.谢谢你的帮助!
βha*_*avḯ 10
试着设置这个,
[txtView setClipsToBounds:YES]; //Confirms subviews are confined to the bounds of the view
[txtView.layer setMasksToBounds:YES]; //Confirms sublayers are clipped to the layer’s bounds
Run Code Online (Sandbox Code Playgroud)
编辑
在您的情况下,kTextFieldCornerRadius的值可能设置为低.
如果我设置kTextFieldCornerRadius = 7;看到我可以得到完美的输出.

尝试增加半径值.
| 归档时间: |
|
| 查看次数: |
10218 次 |
| 最近记录: |