gpt4 book ai didi

ios - CALayer 内边框圆角半径

转载 作者:可可西里 更新时间:2023-11-01 05:04:32 25 4
gpt4 key购买 nike

我有一个 UITextView,我在其图层上设置了边框宽度、边框颜色和圆角半径属性,外部看起来很棒。不过border的内侧没有像外侧那样有圆角,看起来有点滑稽。有没有办法使边框的内角变圆?

编辑:这是我在 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;
}

这是现在的截图:

请注意外角如预期的那样是圆的,但边框的内角是尖的而不是圆的。这就是我要解决的问题。感谢您的帮助!

最佳答案

尝试设置这个,

[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

编辑

可能 kTextFieldCornerRadius 的值在您的情况下设置为较低。

如果我设置 kTextFieldCornerRadius = 7; 看我可以获得完美的输出。

enter image description here

尝试增加半径值。

关于ios - CALayer 内边框圆角半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20258278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com